Em sua declaração If Not Intersect(Target, Range("C20:C200")) Is Nothing Then
Especifique explicitamente em qual folha onde Range ("C20: C200") reside.
Exemplo:
If Not Intersect(Target, YourSheetHere.Range("C20:C200")) Is Nothing Then
Eu tenho 2 Private Sub diferentes (no ThisWorkbook). Cada um está funcionando bem "sozinho".
No entanto, quando ambos são ativados, recebo o erro vba error 1004 method intersect of object _global failed
aparecendo se eu clicar em qualquer célula segmentada no PS # 2 (C20: C200).
A linha de código destacada ao clicar em "debug" está no PS # 1:
If Not Intersect(Target, Range("RSTcabFINISHING")) Is Nothing Then
O que devo fazer para que os dois sub trabalhem juntos?
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
'Initialize cabinet finishing board
If testrange("RSTcabFINISHING") Then
If Not Intersect(Target, Range("RSTcabFINISHING")) Is Nothing Then
Target.Offset(0, 1).Resize(, 3).ClearContents
End If
End If
If testrange("RSTcabMATERIAL") Then
If Not Intersect(Target, Range("RSTcabMATERIAL")) Is Nothing Then
Target.Offset(0, 1).Resize(, 3).ClearContents
End If
End If
Application.EnableEvents = True
End Sub
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
'AUTO COMPLETE - initialize the script (to 0) each time a cell is selected in col "C")
If Selection.Count = 1 Then
If Not Intersect(Target, Range("C20:C200")) Is Nothing Then
Worksheets("HARD").Range("AUTOCOMPhardwareVBASCRIPT").Value = 0
Worksheets("ACC-ST").Range("AUTOCOMPaccessoriesSTVBASCRIPT").Value = 0
Worksheets("ACC-SP").Range("AUTOCOMPaccessoriesSPVBASCRIPT").Value = 0
End If
End If
End Sub
Em sua declaração If Not Intersect(Target, Range("C20:C200")) Is Nothing Then
Especifique explicitamente em qual folha onde Range ("C20: C200") reside.
Exemplo:
If Not Intersect(Target, YourSheetHere.Range("C20:C200")) Is Nothing Then
Tags microsoft-excel vba