Is there a way to trigger Worksheet_Change code after modules execute?

djjack37

New Member
Joined
Jan 20, 2016
Messages
7
I've got a workbook consisting of 3 tabs (book2) with some pretty elaborate logic to populate the tabs with data based on the import of another workbook (book1). Once the data is brought in, I want to setup Worksheet_Change logic on certain ranges in book2 to highlight changes to the default data.

Does anyone have any ideas on how to do this (or if it's even possible)? Maybe set some variable in the book2 module that loads the data from book1 that forces the worksheet change event to fall out of the sub until complete?
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Hi,
Welcome to the board.
It is possible to call a Worksheet_Change event from a procedure in standard module if that is what you require. However, probably much simpler if you need to use same code from different places in your project to create it as a common a code (you can pass Range object to your common code as an argument) & call that from where needed.
As an example:

Worksheet Change Event:

Code:
 Private Sub Worksheet_Change(ByVal Target As Range)   
 If Not Intersect(Target, Range("A10")) Is Nothing Then
    CommonCode Target
    End If
End Sub

Common code in standard module:

Code:
 Sub CommonCode(ByVal Target As Range)    
  MsgBox Target.Address
End Sub

Common code called from another code.
Code:
 Sub CallCommonCode()    
 CommonCode Range("A10")
End Sub

You can if needed turn off the worksheet change event by setting Application.EnableEvents = False
You must though, reset this back to True when processing completed.

Hope Helpful

Dave.
 
Last edited:
Upvote 0
Solution

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

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