LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Scope of Public Variable

I want to create a Public variable upon the opening or reactivation of a
workbook.
Public wbVLA08 = Application.ActiveWorkbook

Then at various points in several modules I activate a different workbook,
do something there, and then want to make sure the original workbook is
activated. So I'd use:
wbVLA08.Activate

When a routine is called by another macro in which the Public variable has
been set, I get flagged on it saying object hasn't been set. "Run-time error
91: Object variable or With block variable not set"

Do I need to declare the variable in every module in which it is used? Do I
need to set in each module? Do I need to make it static?

If I understand it, I can't set in "This Workbook" which is what I'd like to
do.

How can I do this?


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Name Scope Slim Slender[_2_] Excel Worksheet Functions 2 December 16th 09 01:38 AM
Set Public Variable on Open jlclyde Excel Discussion (Misc queries) 4 September 11th 09 07:03 PM
Public variable Jack New Users to Excel 4 March 18th 06 09:35 PM
public variable marwan hefnawy Excel Programming 1 September 5th 03 08:54 AM
Scope of variable includes all Form _and_ Code modules?? John Wirt[_2_] Excel Programming 5 August 18th 03 08:27 AM


All times are GMT +1. The time now is 11:02 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"