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

Passing a workbook name to a variable

Status
Not open for further replies.

Mollethewizard

IS-IT--Management
Nov 18, 2002
93
SE
Probably this is very simple but I haven’t found the solution.

Is there a way to pass a workbook name to a variable? It would be most helpful if the variable could be used in different modules within a project. The variable is to be used like “name.activate” , name.close savechanges = no etc.


Mollethewizard
 
You can assign it to a variable as:

Dim w As Workbook
Set w = Application.ActiveWorkbook

and you can reference w instead of activeworkbook.

You can put the Dim statement in the Declarations but not the Set. This way you will need to Set the variable once in each module.

Bogiemon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top