我被困在这一个。我无法确定问题吗?我有这些代码,似乎它不起作用。有人可以帮我调试这个吗?您的回答将不胜感激!谢谢! :)
Private Sub cmdIn_Click()
Dim DateToday As Date
Dim WeekdayToday As String
Dim Name As String
Dim ws As Worksheet
Set ws = Worksheets("Sept 14 - Sept 20")
ws.Activate 'this will activate the worksheet that you will be working on
DateToday = DateValue(Now)
WeekdayToday = WeekdayName(Weekday(DateToday))
Name = txtNickname.Value
If Name = jane Then
Select Case WeekToday
Case Is = "Sunday"
ws.Range("B7") = Val(lblTime.Caption)
Case Is = "Monday"
ws.Range("F7") = Val(lblTime.Caption)
Case Is = "Tuesday"
ws.Range("J7") = Val(lblTime.Caption)
Case Is = "Wednesday"
ws.Range("R7") = Val(lblTime.Caption)
Case Is = "Thursday"
ws.Range("T7") = Val(lblTime.Caption)
'ws.[T7].Value = Val(lblTime.Caption)
Case Is = "Friday"
ws.Range("V7") = Val(lblTime.Caption)
Case Is = "Saturday"
ws.Range("Z7") = Val(lblTime.Caption)
End Select
End If
End Sub
答案 0 :(得分:0)
你好先生两个问题选择Case WeekToday应该是Select Case WeekdayToday而如果name = jane应该是name =“jane”,看下面的代码是固定的。
Dim DateToday As Date
Dim WeekdayToday As String
Dim Name As String
Dim ws As Worksheet
Set ws = Worksheets("Sept 14 - Sept 20")
ws.Activate 'this will activate the worksheet that you will be working on
DateToday = DateValue(Now)
WeekdayToday = WeekdayName(Weekday(DateToday))
Name = txtNickname.Value
'Fixed jane to "jane"
If Name = "jane" Then
'Fixed WeedTodays to WeekdayToday.
Select Case WeekdayToday
Case Is = "Sunday"
ws.Range("B7") = Val(lblTime.Caption)
Case Is = "Monday"
ws.Range("F7") = Val(lblTime.Caption)
Case Is = "Tuesday"
ws.Range("J7") = Val(lblTime.Caption)
Case Is = "Wednesday"
ws.Range("R7") = Val(lblTime.Caption)
Case Is = "Thursday"
ws.Range("T7") = Val(lblTime.Caption)
'ws.[T7].Value = Val(lblTime.Caption)
Case Is = "Friday"
ws.Range("V7") = Val(lblTime.Caption)
Case Is = "Saturday"
ws.Range("Z7") = Val(lblTime.Caption)
End Select
End If
End Sub