On_change event not triggering

ouvay

Board Regular
Joined
Jun 9, 2022
Messages
131
Office Version
  1. 2019
Platform
  1. Windows
Hello,

Here is my code which is meant to trigger on change
upon triggering, it is suppose to run another function referenced in the code (not pasting due to relavance)

I've got the code in the "Management Sheet" module
unfortunately, it isn't working.. I'd appreciate you guys's help on this

Thanks in advance

Code Below
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

Dim v
Dim reason_ws As Worksheet: Set reason_ws = ThisWorkbook.Worksheets("Reason List")
Dim manage_ws As Worksheet: Set manage_ws = ThisWorkbook.Worksheets("Management Sheet")
Dim watchingRng As Range: Set watchingRng = reason_ws.Range("C2:C" & reason_ws.Cells(Rows.Count, 3).End(xlUp).Row)



If Intersect(Target, watchingRng) Is Nothing Then Exit Sub
v = getUniqueArray(watchingRng)
If IsArray(v) Then
   manage_ws.Range("a2").Resize(UBound(v)) = v
End If


End Sub
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Hi,

First, make sure that event-driven is working. Put the following code in the Immediate window in the VBE then press [Enter].

VBA Code:
Application.EnableEvents=True


If Intersect(Target, watchingRng) Is Nothing Then Exit Sub
Stop the code here, and check if it goes to Exit Sub or not.
 
Upvote 0
In addition to @Colo's comments ...

It looks like you want to monitor changes in Worksheets("Reason List")? If so, that's the sheet module where you need to put this Sub.

If this code is in the "Management Sheet" module, it will trigger only if you make changes to "Management Sheet". And if you do, this line will error:

VBA Code:
If Intersect(Target, watchingRng) Is Nothing Then Exit Sub

because you can't apply Intersect to two different worksheets.
 
Upvote 0
Solution
In addition to @Colo's comments ...

It looks like you want to monitor changes in Worksheets("Reason List")? If so, that's the sheet module where you need to put this Sub.

If this code is in the "Management Sheet" module, it will trigger only if you make changes to "Management Sheet". And if you do, this line will error:

VBA Code:
If Intersect(Target, watchingRng) Is Nothing Then Exit Sub

because you can't apply Intersect to two different worksheets.
Thank you! I just needed to move the code over to the "Reason List" sheet! :)
 
Upvote 0

Forum statistics

Threads
1,223,270
Messages
6,171,102
Members
452,379
Latest member
IainTru

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