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 Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using general variables

Status
Not open for further replies.

mayki76

MIS
Joined
May 18, 2003
Messages
5
Location
IL
i am writing a macro for excel.
i have few subs.
there are some variables (like "file_name") which i would like to use in all the subs.
how to i do so?

(i declared them in the "general")
 
The Answer is at the top of your module put

Public file_name as string

or if the value doesnt change

const file_name = "C:\whatever"

but from your question, i suggest you read the excel vba files on scope and declaration, as you wont get much further.,

Chance,

Filmmaker, taken gentleman and crunch day + 22
 
that's exactly what i did but from some reason it doesnt work. i am not familiar with vba enough to understand why.

 
might help if you post your code.

Chance,

Filmmaker, taken gentleman and crunch day + 22
 
thanks.
problem solved - i figured global variables are active as long as you run all subs.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top