ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Creating a macro to name several tabs (https://www.excelbanter.com/excel-discussion-misc-queries/54163-creating-macro-name-several-tabs.html)

BitsofColour

Creating a macro to name several tabs
 
I have this macro:
Sub Macro()
Sheets(1).Name = Range("b1").Value
Range("B17").Select

End Sub

and it works in renaming the tab to whatever is in cell "B1" but I have 30+
tabs that I need to run this for and I can't figure out the rest of the macro
needed for this to go thru all of the tabs and not just the first one.

Any help would be appreciated!

Thanks


Rowan Drummond

Creating a macro to name several tabs
 
Try:

Sub macro()
Dim i As Integer
On Error Resume Next
For i = 1 To Sheets.Count
Sheets(i).Name = Sheets(i).Range("B1").Value
Next i
On Error GoTo 0
End Sub

Hope this helps
Rowan

BitsofColour wrote:
I have this macro:
Sub Macro()
Sheets(1).Name = Range("b1").Value
Range("B17").Select

End Sub

and it works in renaming the tab to whatever is in cell "B1" but I have 30+
tabs that I need to run this for and I can't figure out the rest of the macro
needed for this to go thru all of the tabs and not just the first one.

Any help would be appreciated!

Thanks


BitsofColour

Creating a macro to name several tabs
 
Thank you - that works great!

"BitsofColour" wrote:

I have this macro:
Sub Macro()
Sheets(1).Name = Range("b1").Value
Range("B17").Select

End Sub

and it works in renaming the tab to whatever is in cell "B1" but I have 30+
tabs that I need to run this for and I can't figure out the rest of the macro
needed for this to go thru all of the tabs and not just the first one.

Any help would be appreciated!

Thanks


Rowan Drummond

Creating a macro to name several tabs
 
You're welcome.

BitsofColour wrote:
Thank you - that works great!



All times are GMT +1. The time now is 11:48 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com