gpt4 book ai didi

excel - 编译错误 : Expected: =

转载 作者:行者123 更新时间:2023-12-04 19:53:33 25 4
gpt4 key购买 nike

在 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 中,如果你没有将函数的返回值赋给任何东西,或者如果方法是一个 SubRoutine,你就可以省略括号,所以试试这个:

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

关于excel - 编译错误 : Expected: =,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18125215/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com