PDA

View Full Version : [SOLVED:] HOw to run a macro automaticcaly when open a workbook



Pasi12
01-31-2014, 03:30 PM
Hello,

Need to know how to run a macro / module automatically when I open my worksheet. I used below code but it wont run, any idea?
Thanks.
Pasi



'Private Sub Workbook_Open()

Date
call myMacro
End Sub

ashleyuk1984
01-31-2014, 03:54 PM
I'm sure your meant to have the code in this section.

http://www.ultraimg.com/images/FkVmj.png

Pasi12
01-31-2014, 03:57 PM
HI Ashley,

Well I have an personal.xlsm and all my modules are there. DO I need to save it to "this workbook"?

Pasi12
01-31-2014, 04:05 PM
I try to save it in "this work book"but its telling me to have to save it in a macro enabled file and that's my personal.xlsm .?

ashleyuk1984
01-31-2014, 04:33 PM
I presume you'll only be running this particular macro on one workbook each time you open it?

If that's the case, open that workbook, and save the macro in "ThisWorkbook" and then SAVE the file as XLSM format.
Then each time you open that workbook your macro will run, and presumably it will be calling a macro that is saved in your personal.xlsm file.

Pasi12
01-31-2014, 04:43 PM
11197

Ok here is what I am getting I save the file as xlsm??

ashleyuk1984
01-31-2014, 05:00 PM
OK, you can't just call a macro like that... Because it's looking for the macro FindDuplicates within Book2.xlsm, which doesn't exist.
So you need to call it from another workbook.

Try doing this:


Application.Run "PERSONAL.XLSB!FindDuplicates"

Instead of Call FindDuplicates

Pasi12
01-31-2014, 05:14 PM
No its not working?? not sure whats going on? when I tried to save it itgave me msg that it can not be saved in a macro-free workbook, you need to save it in a macro enabled file and I did and now its not working?
hmm??

Pasi12
01-31-2014, 05:30 PM
OK Got it to work... thanks!