我在下面的代碼行中得到了對象所需的運行時錯誤,我檢查了它們的正確表名,但仍然顯示相同的錯誤Sheet1.Range(「A1」)。Value = Date & 「」 &時間對象所需運行時錯誤'424'
Private Sub CommandButton1_Click()
Dim username As String
Dim password As String
username = TextBox1.Text
password = TextBox2.Text
Dim info
info = IsWorkBookOpen("D:\TMS_Project\username-password.xlsx")
If info = False Then
Workbooks.Open ("D:\TMS_Project\username-password.xlsx")
End If
Dim x As Integer
x = 2
Do While Cells(x, 1).Value <> ""
If Cells(x, 1).Value = username And Cells(x, 2).Value = password Then
MsgBox "Welcome!"
Sheet1.Range("A1").Value = Date & " " & Time
Selection.NumberFormat = "m/d/yyyy h:mm AM/PM"
UserForm1.Hide
ActiveWorkbook.Close True
End
Else
x = x + 1
End If
Loop
MsgBox "Please check your username or password!"
ActiveWorkbook.Close True
TextBox1.Text = ""
TextBox2.Text = ""
TextBox1.SetFocus
End Sub
它是'Sheet1'的'CodeName',不一定是你的工作表的名字,對吧? –
我想我解決了它的工作表(「Sheet1」)。Range(「A1」)。Value = Date&「」&Time – Kittu
@shai你說的也是正確的..我會試試這種方式 – Kittu