Results 1 to 8 of 8

Compile Error, expecting Sub

Threaded View

  1. #1
    Registered User
    Join Date
    01-07-2010
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    4

    Compile Error, expecting Sub

    Hi Guys,

    I am completely new to vba and was wondering if anyone could explain why this wont run for me?:

    Option Explicit
    Sub ReNumber()
    
        Dim ws As Worksheet
        Dim stepCounter, manualStepNum, currentStepNum
        stepCounter , currentStepNum = 1
        
        Set ws = Workbooks("blah.xls")
        
        For Each ws In Worksheets
        
        Do Until (Range("A" & stepCounter).Text = "")
            If Left(Range("A" & stepCounter).Text, 4) = "Test" Then
                manualStepNum = Right(Range("A" & stepCounter).Text, 1)
                currentStepNum = 1
            End If
            
            If Left(Range("A" & stepCounter).Text, 4) = "Step" Then
                Range("A" & stepCounter).Value = "Step " & manualStepNum & "." & currentStepNum
                currentStepNum = currentStepNum + 1
            End If
            stepCounter = stepCounter + 1
        Next
    
    End Sub
    Whenever I try to run this I get a compile error which says that It was expecting a Sub, Function or Property and then highlights the "Sub" line
    Last edited by Rhubarb; 01-07-2010 at 08:56 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1