No announcement yet.

Compile error expected =

  • Filter
  • Time
  • Show
Clear All
new posts

  • Compile error expected =

    I have the following code:

    Sub StartTimer(Interval As String, CopySheet As String, PasteSheet As String)
        runWhat = "CopyData(CopySheet, PasteSheet)"
        dTime = Int(Now) + TimeSerial(Hour(Now), Minute(Now), Second(Now) + 1) 'Set time interval
        Application.OnTime dTime, runWhat, schedule:=True            'Schedule macro run
        With ThisWorkbook.Worksheets("data")        'Name of worksheet with start/stop button
            .Range("A1") = "Macro Started"
        End With
    End Sub
    Sub CopyData(CopySheet As String, PasteSheet As String)
       Dim NextRow As Long
        With ThisWorkbook.Worksheets(CopySheet)        'Name of worksheet to copy from
            .Range("A2:G2").Copy               'Range to copy
        End With
        With ThisWorkbook.Worksheets(PasteSheet)  'Name of worksheet to copy to
            NextRow = .Range("A65536").End(xlUp).Row + 1 'Increment Row
            .Range("A" & NextRow).PasteSpecial Paste:=xlPasteValues 'Paste to new row
            TimeStamp = FormatDateTime(Now(), vbShortDate) + " " + FormatDateTime(Now(), vbShortTime)              'Timestamp the entry
            TimeStampCell = .Range("H" & NextRow) 'Column to paste timestamp
            If IsEmpty(TimeStampCell) Then          'Check if cell is empty
                .Range("H" & NextRow) = TimeStamp     'If so paste timestamp
            End If
        End With
       Module1.StartTimer("hour", CopySheet, PasteSheet)
       'Schedule next run
    End Sub
    The problem is this line:

    Module1.StartTimer("hour", CopySheet, PasteSheet)
    I get a compile error expected =

    Help is appreciated! Thanks in advance!

  • #2

    Re: Compile error expected =

    Hi Canuck

    When you use Parenthesis Excel expects you to pass the result. Try removing BOTH Parenthesis.