附加是我在工作表中使用的代碼。這代碼直到最後一點工作。最後一個代碼的第一行是錯誤的地方...... Private Sub Worksheet_SelectionChange(ByVal Target As Range)
我想知道爲什麼,它似乎與其他兩個主題一起工作。獲取編譯錯誤:檢測到模糊名稱:Worksheet_Selection更改
如果有人能幫助它,將不勝感激。
Option Explicit
Dim PreviousValue
Private Sub Worksheet_Change(ByVal Target As Range)
Dim sLogFileName As String, nFileNum As Long, sLogMessage As String
Dim NewVal
On Error GoTo Whoa
Application.EnableEvents = False
sLogFileName = ThisWorkbook.path & Application.PathSeparator & "Open Order Log.txt"
If Not Target.Cells.Count > 1 Then
If Target.Value <> PreviousValue Then
If Len(Trim(Target.Value)) = 0 Then _
NewVal = "Blank" Else NewVal = Target.Value
sLogMessage = Now & Application.UserName & _
" changed cell " & Target.Address & " from " & _
PreviousValue & " to " & NewVal
nFileNum = FreeFile
Open sLogFileName For Append As #nFileNum
Print #nFileNum, sLogMessage
Close #nFileNum
End If
End If
LetsContinue:
Application.EnableEvents = True
Exit Sub
Whoa:
MsgBox Err.Description
Resume LetsContinue
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
PreviousValue = Target(1).Value
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim sLogFileName As String
End Sub
If FileLen(sLogFileName) > 3145728# Then
sLogFileName = "Open Order Log - " & Format(Date, "dd-mm-yyyy")
Name sLogFileName As "ThisWorkbook.path & Application.PathSeparator & \Temp\Open Order Log - " & Format(Date, "dd-mm-yyyy")
End If
End Sub
您是否看到我對您上一個問題的回答?它解決了在一個編輯中跟蹤多個單元。 –
哪個問題,我問到最近多個問題。 –
昨天輸入相同的密碼。 http://stackoverflow.com/questions/12203020/i-have-a-code-to-log-usage-in-an-excel-sheet-but-i-get-one-bug-and-one-issue/ 12205874#12205874 –