ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Wanted: Syntax for Filename changed without impacting Macro (https://www.excelbanter.com/excel-programming/379877-wanted-syntax-filename-changed-without-impacting-macro.html)

bluegrassstateworker

Wanted: Syntax for Filename changed without impacting Macro
 
Hello,
I have the following line of code that was created by the macro
recorder:

Application.Run "CHFSform98g2.xls!S6Exp"

This runs a macro in the current spreadsheet called S6Exp. My dilema
is that the name of the spreadsheet (CHFSform98g2) changes, creating an
error in the macro. Is there a good syntax that will run S6Exp
regardless of the filename?

Thanks


bluegrassstateworker

Wanted: Syntax for Filename changed without impacting Macro
 
I guess with the holidays my mind is somewhere else; perhaps in a
sugar-buzz haze.....

I used the CALL command:
CALL S6Exp
and that worked! Merry Christmas everyone!
-- A

Jim Jackson wrote:
You should be able to change the line to Application.Run "S6Exp" and have
it work.
--
Best wishes,

Jim


"bluegrassstateworker" wrote:

Hello,
I have the following line of code that was created by the macro
recorder:

Application.Run "CHFSform98g2.xls!S6Exp"

This runs a macro in the current spreadsheet called S6Exp. My dilema
is that the name of the spreadsheet (CHFSform98g2) changes, creating an
error in the macro. Is there a good syntax that will run S6Exp
regardless of the filename?

Thanks




Dave Peterson

Wanted: Syntax for Filename changed without impacting Macro
 
Is S6Exp a procedure in the same workbook's project?

If yes:
call S6Exp



bluegrassstateworker wrote:

Hello,
I have the following line of code that was created by the macro
recorder:

Application.Run "CHFSform98g2.xls!S6Exp"

This runs a macro in the current spreadsheet called S6Exp. My dilema
is that the name of the spreadsheet (CHFSform98g2) changes, creating an
error in the macro. Is there a good syntax that will run S6Exp
regardless of the filename?

Thanks


--

Dave Peterson


All times are GMT +1. The time now is 01:58 AM.

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