Passing a value across workbooks

O

Otto Moehrbach

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
 
B

Bob Phillips

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top