Whenever a user is editing a cell and switching the sheet while editing, the following error message appears:
Run-time error '1004':
Method 'Intersect' of object '_Global' failed
Here's the code:
Private Sub Workbook_SheetChange(ByVal sh As Object, ByVal Target As Range)
'If Changes Intersect with Data Inventory Range
If Not Intersect(Target, Range(Range("E6"), Range("E" & Cells(Rows.Count, 2).End(xlUp).Row))) Is Nothing Then
If (TypeName(Target.Value) = "String") Then 'Distinction between pressing button and modifying process name
If Target.Value <> ChangeTrack Then 'Prevents duplicate check from being called if Process name stays the same
Call generate_ID(Target.Value, Target, sh)
End If
End If
End If
End Sub
Sorry for the nested if statements (for some reason it doesn't work if I link up multiple statements with the 'And' operator inbetween?)
I think it has to do with range comparisons between different sheet, that lead to a crash in the Intersect method but I also tried to explicitly define the Range with sh.Range(...) with no luck.