ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Run a macro shortcut from another macro? (https://www.excelbanter.com/excel-programming/315898-run-macro-shortcut-another-macro.html)

George J

Run a macro shortcut from another macro?
 
I use Ctrl+n to run a macro

I now need to run this macro from another macro.
Tried using SendKeys "^%n", Wait:=True
but this didn't work. I cannot directly reference the
macro as there may be another workbook open (as
thisworkbook) that contains the same macro name but works
slightly differently - but if CTRL+n is pressed i have set
it up so that the macro from the activeworkbook will run.

can anyone help?
thanks
George

Dick Kusleika[_4_]

Run a macro shortcut from another macro?
 
George

Consider using Application.Run to call it from the other workbook. You can
specify which workbook's macro to run.

Application.Run("Book1.xls!MyMacro")

MyMacro must be Public and in a standard module.

--
Dick Kusleika
MVP - Excel
Excel Blog - Daily Dose of Excel
www.dicks-blog.com

"George J" wrote in message
...
I use Ctrl+n to run a macro

I now need to run this macro from another macro.
Tried using SendKeys "^%n", Wait:=True
but this didn't work. I cannot directly reference the
macro as there may be another workbook open (as
thisworkbook) that contains the same macro name but works
slightly differently - but if CTRL+n is pressed i have set
it up so that the macro from the activeworkbook will run.

can anyone help?
thanks
George





All times are GMT +1. The time now is 10:11 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com