well I have a big doubt, actually I'm developing a excel vba application, but I have a problem, I'm using the event of worksheet (Worksheet_Change
), but I want that this event doesn't execute if macro is running...
The macro runs or enable when the user press a button, so I want that if the user click the button (active the macro) all the logic or functions that I have in Worksheet_Change can not be executed..
I have this in my worksheet_change:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim aCell As Range, Rng As Range
Dim SearchString As String
Dim myValue As Variant
Set Rng = Range("F10:F153")
Dim myList As Object
Set myList = CreateObject("Scripting.Dictionary")
myList.Add "1234", 1
myList.Add "12345", 2
myList.Add "123456", 3
SearchString = "Error"
For Each aCell In Rng
If InStr(1, aCell.Value, SearchString, vbTextCompare) Then
MsgBox "Error encontrado. "
myValue = InputBox("Inserte el numero de empleado de algun operador de calidad")
If myList.Exists(myValue) Then
MsgBox "Numero de empleado correcto, verifique su error."
Else
While myList.Exists(myValue) = False
myValue = InputBox("Inserte el numero de empleado de algun miembro de calidad")
Wend
MsgBox "Numero de empleado correcto, verifique su error."
End If
End If
Next
End Sub