Excel VBA Course
Excel VBA Course - From Beginner to Expert

200+ Video Lessons
50+ Hours of Video
200+ Excel Guides

Become a master of VBA and Macros in Excel and learn how to automate all of your tasks in Excel with this online course. (No VBA experience required.)

View Course

Worksheet_Open and Worksheet_Change Code

0

Any advice appreciated.

I have Worksheet_Open code in ThisWorkBook which obviously performs actions when the spreadsheet is opened. What I woud like to do is get the same code to run when a Worksheet_Change event occurs in a particular sheet.

Assuning I can't combine Worksheet_Open & Change in a single module(?) how can I call one from the other?

Apologies if this is a question driven by general lack of appreciation of the structure of VBA but any input would help.

Thanks

JK

Answer
Discuss

Discussion

Try out my solution and if it doesn't work let me know.

Also, when you get an answer that works, don't forget to "Select" it by clicking the "Select Answer" button at the bottom of it and then clicking "Yes". It doesn't have to be my answer, it's just that some people are not aware of this whole "selecting answer" process.
don (rep: 1989) Jul 13, '16 at 1:00 pm
Add to Discussion

Answers

0

Basically, they call themselves when an action happens.

If you want a particular piece of code to be executed by either of them then just put the macro into its own section in a Module and call the macro from the Worksheet_Open and Change events.

This way, you can access the code from wherever you want in the VBA environment.

To call the macro, you basically just write:

Call macros_name

Here is a small tutorial on it: call a macro from another macro

Discuss

Discussion

Many thanks for the response Don.
JohnK Jul 13, '16 at 12:51 pm
Add to Discussion


Answer the Question

You must create an account to use the forum. Create an Account or Login