我對此仍然比較陌生,並試圖找到答案。也許它沒有正確定義或根本沒有定義。也許它不是指向正確的工作表。我不太確定...任何幫助將不勝感激!謝謝!運行時錯誤'1004':對象'_Global'的方法'相交'失敗
獲取有關此行錯誤:
Set Inte = Intersect(A, Target)
錯誤代碼是:
Run-time error '1004': Method 'Intersect' of object'_Global' failed
全碼:
Private Sub Worksheet_Change(ByVal Target As Range)
'Determine Target Colunm
If Target.Column = 10 Then
'Check for "TD", Copy/Delete Row if found
If Target = "TD" Then
Application.EnableEvents = False
nxtRow = Sheets("TD Locks").Range("J" & Rows.Count).End(xlUp).Row + 1
Target.EntireRow.Copy _
Destination:=Sheets("TD Locks").Range("A" & nxtRow)
Target.EntireRow.Delete
Application.EnableEvents = True
Exit Sub
End If
'Check for "Closed", Copy/Delete Row if found
If Target = "Closed" Then
Application.EnableEvents = False
nxtRow = Sheets("Closed Locks").Range("J" & Rows.Count).End(xlUp).Row + 1
Target.EntireRow.Copy _
Destination:=Sheets("Closed Locks").Range("A" & nxtRow)
Target.EntireRow.Delete
Application.EnableEvents = True
End If
End If
'Adds date when borrower name is entered
Dim A As Range, B As Range, Inte As Range, r As Range
Set A = Range("C:C")
Set Inte = Intersect(A, Target)
If Inte Is Nothing Then Exit Sub
Application.EnableEvents = False
For Each r In Inte
If r.Offset(0, 8).Value = "" Then
r.Offset(0, 8).Value = Date
End If
Next r
Application.EnableEvents = True
End Sub
使用'Application.Intersect'嘗試 – PeterT