LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default Passig a variable from one module to another

I am attempting to pass a variable value from one module to another module in
another worksheet.

I first collect the values based on user input in macro 1and then call
macro2 from my "PERSONAL.xls" file to continue processing. Unfortunately, I
need to capture some of the data which was used in the first macro and pass
it along to the 2nd macro.

I've declared the variables "up top" as follows:

Option Explicit
Public xlfile_drive As String
Public period_end As String
Public open_file As String
Public open_file_name As String
Public continueprompt As String

Sub Create_Return_File(xlfile_drive, period_end, open_file, open_file_name,
continueprompt)



periodend = InputBox("Enter reporting month-end in this sample format:
2007-Aug")
xlfile_drive = "T:\mktg\star keystone reporting\Keystone\" & periodend &
"\"
ChDir xlfile_drive
open_file_name = "ROR Series ATC and Models Report-" & Right(periodend,
3) & "-" & Mid(periodend, 3, 2) & ".xls"
open_file = xlfile_drive & open_file_name
....

Further down, I then call the 2nd macro as follows:

Call Add_EPL_Data
....
Public Sub Add_EPL_Data(open_file_name, open_file)
Application.Run "'Personal.xls'!Add_EPL_Returns"
End Sub

Still, the macro is not working and is giving me the error message:

Compile error -- variable not defined.

I had thought, however, that defining it at the global level outside the
subprocedure would resolve this problem?




 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Read Variable from Another Module Mike H. Excel Programming 2 August 27th 07 06:36 PM
STATIC VARIABLE NOT AVAILABLE IN ANOTHER MODULE CAPTGNVR Excel Discussion (Misc queries) 2 February 1st 07 07:30 PM
How to Set a Variable in Another Module? Steve Drenker[_4_] Excel Programming 1 March 17th 06 06:28 PM
Variable in more than one module Nick M[_3_] Excel Programming 2 November 8th 05 07:20 PM
Variable from a sheet module in a class module in XL XP hglamy[_2_] Excel Programming 2 October 14th 03 05:48 PM


All times are GMT +1. The time now is 03:10 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"