Code Isn't Triggering With Worksheet Change Event

Ark68

Well-known Member
Joined
Mar 23, 2004
Messages
4,570
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I am having problems with this code ...

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?
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Maybe:
If Target.Address = ws_form.Range("X" & rwend + 11).Address Then
 
Upvote 0
Solution
Thank you Jaafar for your support. Unfortunately, the line itself is erroneous. No error code, but the line bonks and turns red.
 
Upvote 0
My bad. A typo ... working wonderfully! Thank you.
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,242
Members
452,623
Latest member
russelllowellpercy

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top