I'm trying to rename worksheets 4-34 in an Excel 2010 file. The name list can be found on worksheet 2 named Initial Input (if that is relivant) in b2:31. I came a cross this at this forum and made some minor modifcations:
Sub namesheets()
Dim arr As Variant
arr = Range("b2:b31").Value
For i = LBound(arr) To UBound(arr)
Sheets(i + 1).Activate
Sheets(i).Name = arr(i,1)
Next i
End Sub
It works with the exception of...
(1) I want it to start naming on worksheet 4, not worksheet 1.
(2) I get an error code after it runs out of names so I assume it needs some type of "get out of loop" function but I don't know how to build it in.
I know just enough to be dangerous so if someone could help me that would be awesome!
Thanks in advance.
Sub namesheets()
Dim arr As Variant
arr = Range("b2:b31").Value
For i = LBound(arr) To UBound(arr)
Sheets(i + 1).Activate
Sheets(i).Name = arr(i,1)
Next i
End Sub
It works with the exception of...
(1) I want it to start naming on worksheet 4, not worksheet 1.
(2) I get an error code after it runs out of names so I assume it needs some type of "get out of loop" function but I don't know how to build it in.
I know just enough to be dangerous so if someone could help me that would be awesome!
Thanks in advance.