rename worksheet by cell value

trancer23

New Member
Joined
Apr 14, 2003
Messages
11
can i write a macro to rename a worksheet by a cell value

i have a macro that generates lots of charts and i would like to name them based on a cell value

thanx
jeff
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
cool thanx, unfortunately b/c its in a loop i need something along the lines of

ActiveSheet.Name = Cells(1, startcol).Value

but that doesnt work.. startcol is column variable

thanx
jeff
 
Upvote 0
I'd really need to see your workbook and the macro you've created to see what it is you are really trying to accomplish but you could create a variable for startcol and increment it within your loop:

Dim StartCol as integer

' Your loop
Activesheet.Name = Cells(1, StartCol).Value
StartCol = StartCol + 1
' Loop
 
Upvote 0
here is my macro:

Worksheets("Sheet1").Activate
startcol = 1
For profile = 1 To 240
Range(Cells(1, startcol), Cells(400, startcol + 1)).Select
Charts.Add
ActiveChart.ChartType = xlXYScatterLines
ActiveChart.Location Where:=xlLocationAsNewSheet
Sheets("Sheet1").Select
startcol = startcol + 2
profile = profile + 1
Next profile


why sheet names are in row one1, every other one, hence the startcol +2 counter

thanx
 
Upvote 0
try:

Worksheets("Sheet1").Activate
startcol = 1
For profile = 1 To 240
Range(Cells(1, startcol), Cells(400, startcol + 1)).Select
Charts.Add
ActiveChart.ChartType = xlXYScatterLines
ActiveChart.Location Where:=xlLocationAsNewSheet
Activesheet.Name = Range(Cells(1, startcol)).Value
Sheets("Sheet1").Select
startcol = startcol + 2
profile = profile + 1
Next profile
 
Upvote 0
still fails on the renaming line

Run-time error '1004':

Method 'Range" of object '_Global" Failed

any ideas?
 
Upvote 0
TRY THIS:

Worksheets("Sheet1").Activate
startcol = 1
For profile = 1 To 240
Range(Cells(1, startcol), Cells(400, startcol + 1)).Select
Charts.Add
ActiveChart.ChartType = xlXYScatterLines
ActiveChart.Location Where:=xlLocationAsNewSheet
Activesheet.Name = Sheets("Sheet1").Cells(1, startcol).Value
Sheets("Sheet1").Select
startcol = startcol + 2
profile = profile + 1
Next profile
 
Upvote 0

Forum statistics

Threads
1,223,111
Messages
6,170,160
Members
452,305
Latest member
chenhi131

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