编译错误:预期:=

在Sub DateDiff中实现Sub TabPaint时出现错误

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 

在VBA中,如果不是将函数的返回值分配给任何东西,或者如果方法是子例程,则省略括号,所以试试这个:

 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 

当你像你的子TabPaint调用子你不能使用括号,所以试试这个:

 TabPaint shn, 255 

而不是这个:

 TabPaint(shn, 255)