![]() |
Passing a value across workbooks
Excel XP & Win XP
I have a WB, say BBB.xls. It has a macro, say MyMacro. MyMacro uses the variable TheRow. The code in BBB.xls calculates the value of TheRow and calls MyMacro. Let's say the last value of TheRow was 20. All works great. I have another WB, say AAA.xls. The code in AAA.xls calculates the value of TheRow as, say 15, and calls MyMacro in BBB.xls with: Application.Run..................... MyMacro runs. The problem: MyMacro uses 20 as the value of TheRow, not 15. My question: How can I pass the new value of TheRow in the MyMacro call? Possible solution is to write a macro in BBB.xls that gets TheRow from AAA.xls and then calls MyMacro, and then have AAA.xls call that new macro instead of MyMacro. This sounds good except for the fact that the file name of the AAA.xls file is a variable. That muddies the water. Thanks for your time. Otto |
Passing a value across workbooks
Change your macro to have arguments, and pass 15 as a call parameter
Application.Run "BBB.xlsmyMacro", TheRow -- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "Otto Moehrbach" wrote in message ... Excel XP & Win XP I have a WB, say BBB.xls. It has a macro, say MyMacro. MyMacro uses the variable TheRow. The code in BBB.xls calculates the value of TheRow and calls MyMacro. Let's say the last value of TheRow was 20. All works great. I have another WB, say AAA.xls. The code in AAA.xls calculates the value of TheRow as, say 15, and calls MyMacro in BBB.xls with: Application.Run..................... MyMacro runs. The problem: MyMacro uses 20 as the value of TheRow, not 15. My question: How can I pass the new value of TheRow in the MyMacro call? Possible solution is to write a macro in BBB.xls that gets TheRow from AAA.xls and then calls MyMacro, and then have AAA.xls call that new macro instead of MyMacro. This sounds good except for the fact that the file name of the AAA.xls file is a variable. That muddies the water. Thanks for your time. Otto |
All times are GMT +1. The time now is 07:32 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com