BobBarker
07-14-2011, 11:52 AM
Can anyone see what's wrong with this little snippet of code?
1004 - Application defined or object-defined error
How helpful is that :P
[edit] SOLVED! Was a problem in my workbook. Worked in a new one~ Silly VBA :/
Public Sub RenameAllWorksheets()
'Declare our variables
Dim ws As Worksheet
Dim dMonth As String
Dim i As Integer
Dim weekend As Integer
dMonth = "May "
i = 1
weekend = 6
For Each ws In Worksheets
If i = weekend Then
i = i + 2
weekend = i + 5
End If
ws.Name = dMonth & i
i = i + 1
Next
End Sub
1004 - Application defined or object-defined error
How helpful is that :P
[edit] SOLVED! Was a problem in my workbook. Worked in a new one~ Silly VBA :/
Public Sub RenameAllWorksheets()
'Declare our variables
Dim ws As Worksheet
Dim dMonth As String
Dim i As Integer
Dim weekend As Integer
dMonth = "May "
i = 1
weekend = 6
For Each ws In Worksheets
If i = weekend Then
i = i + 2
weekend = i + 5
End If
ws.Name = dMonth & i
i = i + 1
Next
End Sub