View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Application.run and ByRef arguments

Try dropping the ()'s in your application.run line and add a couple of "'s.

Application.Run "'Book1.xls'!Macro1", A, B



AsIs wrote:

Hello, all.
I want to run Macro1 from Book1.xls in Macro2 (Book2.xls).
Macro1 has two arguments ByRef:
Public Sub Macro1 (ByRef X As Integer, ByRef Y As Integer)
....
X = X * 2
Y = Y * 3
End Sub

How can I execute Macro1 with passing changed value out from Macro1.
Following code doesn't work:
A = 10
B = 20
Application.run('Book1.xls!Macro1', A, B)
I think Excel passes argyments ByVal (only value, but not reference).
--
Alexander


--

Dave Peterson