Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 52
Default Scope of a public variable

Hi,

I was wondering why Excel sometimes loose my public variables. I use the
variables to have references to my open workbooks and their worksheets.
All my workbooks are open. I suppose that when I open a new workbook en
hides it, I have to rerun my procedure DCL_Sheets? The problem is that most
of the time, everything works fine, but all of a sudden, when I use the
reference eg. shSheet22.[A1]="ABC", I get an error and the reason is because
wbFile1 is not anymore recognized.

Thanks

Jos Vens

eg.

Public wbFile1 as workbook, wbFile2 as workbook
Public shSheet11 as worksheet, shSheet12 as worksheet, shSheet21 as
worksheet, shSheet22 as worksheet

Sub DCL_Sheets

set wbFile1 = workbooks("File1.xls")
set wbFile2 = workbooks("File2.xls")

set shSheet11 = wbFile1.sheets("Sheet01")
set shSheet12 = wbFile1.sheets("Sheet02")
set shSheet21 = wbFile2.sheets("Sheet01")
set shSheet22 = wbFile2.sheets("Sheet02")

End sub



Reply
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
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
Scope of Public Variable Dkline[_2_] Excel Programming 9 October 22nd 03 04:53 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 03:20 PM.

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

About Us

"It's about Microsoft Excel"