![]() |
VBA Apllication.run and macros when spreadsheet name changes
How can change the following statement to run a macro so I do not have to
change the spreadsheet name every time it changes. Application.Run "'Salesman pay 2.9.xls'!Midmonthnumbersmove" 'Salesman pay 2.9.xls' is the spreadsheet name in this example. I would just like the statement to run the macro Midmonthnumbersmove no matter what the spreadsheet name is. |
VBA Apllication.run and macros when spreadsheet name changes
if this is the active workbook, you don't need the spreadsheet name. is this
in some other workbook? -- Gary "newguyoldguy" wrote in message ... How can change the following statement to run a macro so I do not have to change the spreadsheet name every time it changes. Application.Run "'Salesman pay 2.9.xls'!Midmonthnumbersmove" 'Salesman pay 2.9.xls' is the spreadsheet name in this example. I would just like the statement to run the macro Midmonthnumbersmove no matter what the spreadsheet name is. |
VBA Apllication.run and macros when spreadsheet name changes
You can call a macro from an open workbook using....
Call Midmonthnumbersmove -- Cheers Nigel "newguyoldguy" wrote in message ... How can change the following statement to run a macro so I do not have to change the spreadsheet name every time it changes. Application.Run "'Salesman pay 2.9.xls'!Midmonthnumbersmove" 'Salesman pay 2.9.xls' is the spreadsheet name in this example. I would just like the statement to run the macro Midmonthnumbersmove no matter what the spreadsheet name is. |
VBA Apllication.run and macros when spreadsheet name changes
If it is always referring to the activeworkbook, you could use
Application.Run "'" & Activeworkbook.Name & "'!Midmonthnumbersmove" but better would be to set a object variable to the book when you open it, and use that Set oWB = Activewrokbook ... Application.Run "'" & oWB.Name & "'!Midmonthnumbersmove" -- HTH RP (remove nothere from the email address if mailing direct) "newguyoldguy" wrote in message ... How can change the following statement to run a macro so I do not have to change the spreadsheet name every time it changes. Application.Run "'Salesman pay 2.9.xls'!Midmonthnumbersmove" 'Salesman pay 2.9.xls' is the spreadsheet name in this example. I would just like the statement to run the macro Midmonthnumbersmove no matter what the spreadsheet name is. |
VBA Apllication.run and macros when spreadsheet name changes
Works great! thank you very much for your help!
"newguyoldguy" wrote: How can change the following statement to run a macro so I do not have to change the spreadsheet name every time it changes. Application.Run "'Salesman pay 2.9.xls'!Midmonthnumbersmove" 'Salesman pay 2.9.xls' is the spreadsheet name in this example. I would just like the statement to run the macro Midmonthnumbersmove no matter what the spreadsheet name is. |
VBA Apllication.run and macros when spreadsheet name changes
Bob,
Why is your way better? What if the workbook was saved with an other name after opening? Please explain. Grtz, Rody "Bob Phillips" schreef in bericht ... If it is always referring to the activeworkbook, you could use Application.Run "'" & Activeworkbook.Name & "'!Midmonthnumbersmove" but better would be to set a object variable to the book when you open it, and use that Set oWB = Activewrokbook ... Application.Run "'" & oWB.Name & "'!Midmonthnumbersmove" -- HTH RP (remove nothere from the email address if mailing direct) "newguyoldguy" wrote in message ... How can change the following statement to run a macro so I do not have to change the spreadsheet name every time it changes. Application.Run "'Salesman pay 2.9.xls'!Midmonthnumbersmove" 'Salesman pay 2.9.xls' is the spreadsheet name in this example. I would just like the statement to run the macro Midmonthnumbersmove no matter what the spreadsheet name is. |
All times are GMT +1. The time now is 04:45 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com