2 questions:
First, can you have 2 worksheet_change subs for a worksheet? I tried, but it only ran one.
Second, I currently have 1 Worksheet_Change and it is performing 2 functions. The first looks to see if it needs to run the bankemp macro, based on cell information.
the 2nd function it performs pops up a userform if data is entered into column E.
My problem is that the first function keeps repeating no matter what cell i am in and I only need it to perform the bankemp macro once. how do i get it to stop when the user enters data into other cells?
I am pretty sure it runs over and over because the value of A2 doesnt ever change... I tried using a for loop, but either i didnt enter it correctly or vba just doesnt allow 2 for loops because i received an error message "for already in use" when it got to the 2nd function
Here is my code:
First, can you have 2 worksheet_change subs for a worksheet? I tried, but it only ran one.
Second, I currently have 1 Worksheet_Change and it is performing 2 functions. The first looks to see if it needs to run the bankemp macro, based on cell information.
the 2nd function it performs pops up a userform if data is entered into column E.
My problem is that the first function keeps repeating no matter what cell i am in and I only need it to perform the bankemp macro once. how do i get it to stop when the user enters data into other cells?
I am pretty sure it runs over and over because the value of A2 doesnt ever change... I tried using a for loop, but either i didnt enter it correctly or vba just doesnt allow 2 for loops because i received an error message "for already in use" when it got to the 2nd function
Here is my code:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Cells(2, 1) = 1 Then bankemp
For Each cell In Range("E16:E45")
If Not IsEmpty(Cells(Target.Row, 5).Value) Then
Application.EnableEvents = False
WebOrderRole.Show
Application.EnableEvents = True
ElseIf IsEmpty(Cells(Target.Row, 5).Value) Then
Application.EnableEvents = False
Cells(Target.Row, 6).Value = ""
Cells(Target.Row, 7).Value = ""
Cells(Target.Row, 8).Value = ""
Cells(Target.Row, 9).Value = ""
Cells(Target.Row, 10).Value = ""
Cells(Target.Row, 11).Value = ""
Application.EnableEvents = True
End If
Exit For
Next cell
End Sub