Static Variables in Excel VBA

  • 13 years ago

    Hi

    I am trying to build a fairly simple macro in VBA for Excel. I have run into a problem with trying to define a variable that equals ActiveWorkbook.Name. What I want to do is store the name of the workbook I am starting from, then open a few others and re-activate the original one to work on it. If I set a variable to Activeworkbook.Name the value changes every time I open a new workbook, so I lose the name of the oiginal book that I want to return to. I guess Ii could set the variable to Workbooks(1).Name but that won't work if I happen to have more than one book open when I run the macro. I'm sure this will be an easy one for someone to answer - any suggestions?

    Thanks

     

Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“There's no test like production” - Anon