Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

passing variables

Status
Not open for further replies.

Luis939

MIS
Feb 28, 2003
453
US
Pardon my ignorance on the subject, but i want to pass one variable, heres the code

Dim activeinvoice As String
activeinvoice = ActiveWorkbook.Name

I want to declare that variable in one subprocedure and pass that variable to the other procedures that it calls, its not really workin for me, can anyone help, thank you!
 
I'm assuming that you want the variable to be accessed by another sub - in which case just declare it as PUBLIC, at the top of your module - ie BEFORE any subs Rgds
Geoff
"Some cause happiness wherever they go; others whenever they go."
-Oscar Wilde
 
oh ok i see, well before i tried to put the variable name in between the () after the subname, but i dont think i was really doing it right, but thanks
 
I wouldn't use the same name as teh variable that you're passing it to.

Here's a simple example which may point you in the right direction, I've used a function instead of a sub, but the principle's the same:

Code:
Public Function topower3(base as integer) as integer
topower3 = base^3
end function

Sub stickvaluein()
dim baseval as integer
baseval = 5
sheet1.[a1] = topower3(baseval)
end sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top