worksheetname to be selected from a list

DutchKevin

Board Regular
Joined
Apr 13, 2011
Messages
133
Office Version
  1. 365
Platform
  1. Windows
Hi Guys,
I'm trying to get my new worksheet to be renamed to a value from a list of names.
It works if I put a hardcell reference there like "E7", but i'd like it to be incremented every time the macro runs. (Column E holds the names, on sheet "Total")

Code:
Sub Newsheet()
 Dim j As Long
    j = (Sheets.Count)
    Sheets.Add after:=Sheets(Sheets.Count)
    ' ActiveSheet.Name = (Sheets.Count)                         gives a simple seq number to sheet
    ' ActiveSheet.Name = Worksheets("total").Range("c1").Value  gives a defined name to sheet
    ActiveSheet.Name = Sheets("total").Range(5, j).Value
End Sub
Thanks for helping
Kevin
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
In the meanwhile I also have tried
Code:
ActiveSheet.Name = Sheets("total").Cells(5, j).Value
But no luck
Look forward to the sollution.

Kevin
 
Last edited:
Upvote 0
Solved:
For "pulling" the name from column E with Row depending on the value of variable "j"
Code:
ActiveSheet.Name = Sheets("Total").Range("E" & j).Value
Now i still need to foolproof this to prevent the code to be activated beyond the number of entries in column E. That would lead to empty Worksheetname. Also I'll have to think about how to prevent double entries in column "E" somehow. Any tips for doing this in VBA are appreciated.

Thanks for looking
:cool:

Kevin
 
Upvote 0

Forum statistics

Threads
1,224,559
Messages
6,179,513
Members
452,921
Latest member
BBQKING

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top