0

I have various routines in two different modules. Some clears the report, some populates it, fill the blank spaces with zeroes. I am currently running them using F5. But I want when the user opens the sheet, he gets all populated data without having to run that particular sub routine. Is it possible to run the routines in various modules automatically when the excel is opened?

1 Answer 1

1

This is pretty easy. Instead of putting code in the module, you will put it in ThisWorkbook and use the Workbook_Open event. You don't necessarily have to move your code. You can just call the existing macros.

Sign up to request clarification or add additional context in comments.

4 Comments

So I need to call my macro inside Workbook_open event in ThisWorkbook.Is that what you mean?
Yep! That is how you execute code automatically when the workbook opens.
I have two modules with same name sub. So I did module1.func and module2.func, one of them is working correctly, one isn't,am I doing correct?
It worked for me in a quick test, but is there any issue in renaming one of the subs? My test was Private Sub Workbook_Open() Call Module1.test Call Module2.test End Sub and each test sub was a Msgbox to say the module name it was in.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.