I got this error (see title) having the two next Private Sub in ThisWorkbook:
1st Private Sub: is used in a context of cascading dropdown. Thanks to it, if the parent dropdown value change, then the child dropdown is reset by a ClearContents.
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
2nd Private sub: is used in order to reset (value=0) one cell I used as a referrer for another dropdown autocomplete process:
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
Finally, I have the following function in a module, to test if the range target (of the 1st Private Sub) exists in the current sheet:
Function testrange(strRangeName As String) As Boolean
' Local Variables
Dim gExists As Range
On Error Resume Next
Set gExists = Range(strRangeName)
testrange = True
If gExists Is Nothing Then testrange = False
On Error GoTo 0
End Function
First PS is working just fine. But the second one is creating an blocking issue. I guess the point might be the double use of the intersect process, but I have no idea how to change it... Thank you for your help!
برچسب:
نویسنده: استخدام کار