excel - Access a variable of a module in another module after running the program which calls that module? -
i have excel file 2 buttons access 2 different modules. can access variable of module in module after running program calls module?
my modules
1st module..
public sub directory_path() dim directory string directory = inputbox("enter directory path contains folders ""this quarter"",""last quarter"",""second_last_quarter"".") if right(directory, 1) = "\" directory = left(directory, len(directory) - 1) end if end sub
i called the first module in 2nd module using public sub directory_path() . want directory variable in first module used variable in 2nd module...
in 1st module - declare directory public @ top of module outside of sub/function. it's available every module in project:
public directory string sub directory_path() directory = inputbox("enter directory path contains folders ""this quarter"",""last quarter"",""second_last_quarter"".") if right(directory, 1) = "\" directory = left(directory, len(directory) - 1) end if end sub
in 2nd module, use name directory
wherever need it. example:
msgbox "the directory path " & directory
Comments
Post a Comment