naming tabs based on cell

jammoca

Banned
Joined
Nov 6, 2002
Messages
1,100
What I'm looking for is a code that will name a Sheet Tab whatever is in cell A8 of that same sheet.

I don't want all sheets in the workbook named this way only a few.

The name that appears in cell A8 is the result of a formula ( it hasn't been typed in ) i don't know if that makes any difference to the code needed

I've read numerous reviews of this topic and am trying to use the followng code ..

Sub NameSheets()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
ws.Name = ws.Range("a1")
Next ws
End Sub

however it doesn't seem to be doing anything and I suspect it's trying to name all sheets in the workbook .. I don't want that.

Can you please be specific as to where I need to paste the code, eg: is it in Module for that sheet or Class Module etc etc etc you can see I'm a newbie to VBA

sorry
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
yes your macro names ALL the sheets for A1 value in that sheet.
the macro is parked in vb editor

hit alt+F11.and control+R and choose the name of that particuar workbook click aat the top insert=-module . a module window will open and park your macro there.
and then you have to run that macro.

If you want only a few of the sheets named as the cell value at that sheet you have to tell which are these sheets. If it is one or two you manually do it. otherwise clarify which sheets are t o be renamed. There should be some logic in the sheets chosen e.g. first three sheets, last three sheets, three sheets after a particular sheet etc.
 
Upvote 0

Forum statistics

Threads
1,214,642
Messages
6,120,698
Members
448,979
Latest member
DET4492

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