Error with VBA for naming sheet from cell

leecavturbo

Well-known Member
Joined
Jan 4, 2008
Messages
681
I have a pretty standard VBA worksheet name from cell data. but every 7th worksheet or duplicate data the worksheet name references incorrect cell or even sheet!
any ideas ?
Sub tabname()
On Error Resume Next
For Each ws In ThisWorkbook.Worksheets
ws.Name = Left(ws.Cells(10, 1).Value, 31)
Next
On Error GoTo 0
End Sub

also how can this macro auto execute ? i.e i have to run this manually currently
 
but what i have found is if i have created a sheet in readiness for naming but the data isn't in the cell to name that sheet it will use the row before that does have data. it corrects if i add the data run the macro again
 
Upvote 0

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Ok, so if your designated cell is A10, when that cell is changed on sheet20, you want sheet20 name to change to what A10 was changed to or do you want something to happen to all the 200-400 sheet names?
 
Upvote 0
so if i changed mark to shaun sheet 3 name would change to shaun
1635038050444.png
 
Upvote 0
I would suggest a worksheet change event to handle that. Unfortunately I can't think of an easy way to implement that for 200-400 pages at the moment.
 
Upvote 0
I would suggest a worksheet change event to handle that. Unfortunately I can't think of an easy way to implement that for 200-400 pages at the moment.
i would suggest just run macro every second ? it executes extremely fast even doing 200+sheets
 
Upvote 0
@leecavturbo
Rich (BB code):
i would suggest just run macro every second ? it executes extremely fast even doing 200+sheets
As in post #5 ??
 
Upvote 0
ahhh. Another curveball detected.

So the G column on the 'Sat' sheet is where you want the changes to be detected? Example if G5 is changed from 'mark' to 'shaun', Sheet3 should be renamed to 'shaun'?
 
Upvote 0

Forum statistics

Threads
1,214,826
Messages
6,121,793
Members
449,048
Latest member
greyangel23

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