rob_grimshaw
New Member
- Joined
- Jan 18, 2019
- Messages
- 9
Dear all,
I am getting a run-time error for this code, can you help tell me why and how to fix it?
The error reads: "Run-time error 1004: Method 'Intersect' of object '_Global' failed"
It still fails even if I change "
Many thanks.
I am getting a run-time error for this code, can you help tell me why and how to fix it?
Code:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
If ActiveSheet.Name <> "Form" Then End
Dim Form As Worksheet
Dim Data As Worksheet
Set Form = ThisWorkbook.Worksheets("Form")
Set Data = ThisWorkbook.Worksheets("Data")
Dim TargetField As Range
Set TargetField = Form.Range("E4")
Dim SourceField As Range
Set SourceField = Data.Range("A2:A434").Find _
(What:=TargetField, _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
MatchCase:=False)
If Not Intersect(Target, TargetField) Is Nothing Then
Form.Range("I6") = SourceField.Offset(, 29)
Else
Set TargetField = Form.Range("I6")
If Not Intersect(Target, TargetField) Is Nothing Then
SourceField.Offset(, 29) = Form.Range("I6").Value
End If
End If
End Sub
The error reads: "Run-time error 1004: Method 'Intersect' of object '_Global' failed"
It still fails even if I change "
SourceField.Offset(, 29) = Form.Range("I6").Value" to "Offset (,30)" to try and prevent a feedback loop.
Many thanks.