AzIz00
AzIz00

Reputation: 65

Compile error: Expected: =

I got the error when implementing Sub TabPaint within Sub DateDiff

Public Sub TabPaint(ss As Integer, cc As Integer)
  With Sheets(ss).Tab
      .Color = cc
      .TintAndShade = 0
  End With
End Sub


Public Sub DateDiff(date1 As String, date2 As String, shn As Integer)
    If DateDiff("d", date1, date2, vbMonday, vbFirstJan1) < 0 Then
        TabPaint (shn, 255)
    Else
        TabPaint(shn,5287936)
    End If
End Sub

Upvotes: 2

Views: 5946

Answers (2)

Philipp Sander
Philipp Sander

Reputation: 10249

when you call subs like your sub TabPaint you must not use brackets so try this:

TabPaint shn, 255

instead of this:

TabPaint(shn, 255)

Upvotes: 0

JMK
JMK

Reputation: 28059

In VBA, if you aren't assigning the return value of a function to anything, or if the method is a SubRoutine, you leave out the parenthesis, so try this:

Public Sub TabPaint(ss As Integer, cc As Integer)
  With Sheets(ss).Tab
      .Color = cc
      .TintAndShade = 0
  End With
End Sub


Public Sub DateDiff(date1 As String, date2 As String, shn As Integer)
    If DateDiff("d", date1, date2, vbMonday, vbFirstJan1) < 0 Then
        TabPaint shn, 255
    Else
        TabPaint shn, 5287936
    End If
End Sub

Upvotes: 7

Related Questions