Consulting

Results 1 to 2 of 2

Thread: Solved: Strange Error in simple VBA macro

  1. #1

    Solved: Strange Error in simple VBA macro

    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 :/

    [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
    [/vba]
    Last edited by BobBarker; 07-14-2011 at 12:12 PM.

  2. #2
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,060
    Location
    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.
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •