Sub wd()
Dim Isweekday As Boolean
Select Case Weekday(A3, vbSaturday)
Case 1 To 2
Isweekday = False
Case Else
Isweekday = True
End Select
Range("A4").Value = Isweekday
End Sub
这段代码有什么不对吗?...我希望工作日显示为true而非工作日显示为false
答案 0 :(得分:1)
您的代码将A3
视为未声明的变量。
Select Case Weekday(Range("A3").Value, vbSaturday)
更短的:
Sub wd()
Range("A4").Value = (Weekday(Range("A3").Value, vbSaturday) > 2)
End Sub