Worksheet Change Event When A Cell Within A Range Is Changed

Ark68

Well-known Member
Joined
Mar 23, 2004
Messages
4,564
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I have a dynamic range of cells (rng_sstart), that when one of the cells in that range changes, wish to run some code.

This is what isn't working for me:

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim rng_sstart As Range
    
    If Not mbevents Then Exit Sub
    
    With ws_gui1
        Set rng_sstart = .Range("BD4:BD" & .Cells(.Rows.Count, "BD").End(xlUp).Row)
        If Not Intersect(Target, rng_sstart) Is Nothing Then 'CHANGE in staff start
            tgt_r = .Range(Target.Address).Row
            MsgBox "Staff Start - Row: " & tgt_r & Chr(13) & "   - Check for valid time value." & Chr(13) & "   - Check against end time."
            mbevents = True
            Stop
        End If
    End With

This code will not change if I change a value within the range defined by rng_sstart.

Thoughts
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
I can see a few things that might cause that to not work.
  1. That code is not in the code module for whatever sheet ws_gui1 is
  2. The cells in rng_sstart are formulas
  3. Your 'events' have become disabled
 
Upvote 0
Hi Peter, thank you! I had an old application.enableevents=false in my code that I hadn't removed. All good, although it did expose another problem.
 
Upvote 0
You're welcome.

I assume that you have solved the "another problem" or else you will ask about that here or a new thread if required.
 
Upvote 0
Yes, thanks Peter for checking. I did figure that one out on my own :)
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,691
Members
448,978
Latest member
rrauni

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