PDA

View Full Version : Solved: Strange Error in simple VBA macro



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

Aussiebear
07-16-2011, 01:11 AM
Since you took the time to raise the issue in a public forum, any chance that you might share the solution? it is after all a learning experience for others as well.