Ark68
Well-known Member
- Joined
- Mar 23, 2004
- Messages
- 4,570
- Office Version
- 365
- 2016
- Platform
- Windows
I am having problems with this code ...
This code is at the worksheet level. When the user enters a value, it's supposed to trigger the code.
In my testing, rwend =29.
The cell the user is typing in is X40 (rwend + 11 = 29+11 = 40). I put a stop in the code so that I know if the code is reached, but after the user enters the number, the code doesn't fire. Perhaps 'change' isn't the right action for this event, in which case my question would be what would be best?
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = ws_form.Range("X" & rwend + 11) Then
Stop
Dim unx As Integer
unx = CInt(Target.Value)
w_unx = unx / 0.125
If Int(w_unx) <> w_unx Then
MsgBox "Invalid quantity of materials entered." & Chr(13) & "Values may only be increments of 0.125 (1/4 hopper) tonne.", vbInformation, "INVALID DATA"
Application.EnableEvents = False
ws_form.Range("W37") = ""
Application.EnableEvents = True
End If
End If
End Sub
This code is at the worksheet level. When the user enters a value, it's supposed to trigger the code.
In my testing, rwend =29.
The cell the user is typing in is X40 (rwend + 11 = 29+11 = 40). I put a stop in the code so that I know if the code is reached, but after the user enters the number, the code doesn't fire. Perhaps 'change' isn't the right action for this event, in which case my question would be what would be best?