Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Can excel objects be defined as global variables

I want to define such items as
public ws as worksheet
public rg as range

I put them in the general declarations for "This Workbook". All other
variables such as integer, string etc. are behaving as global. But not the
objects. I read some discussion about defining them as I indicated above,
but when I go to another module, it gives me the error that the name is not
defined.
Can objects be global? If so, is there a certain place they have to be
defined
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default Can excel objects be defined as global variables

Define them in a normal Module and it should work fine.

RBS


"Phyllis" wrote in message
...
I want to define such items as
public ws as worksheet
public rg as range

I put them in the general declarations for "This Workbook". All other
variables such as integer, string etc. are behaving as global. But not the
objects. I read some discussion about defining them as I indicated above,
but when I go to another module, it gives me the error that the name is
not
defined.
Can objects be global? If so, is there a certain place they have to be
defined


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,836
Default Can excel objects be defined as global variables

It has to be declared as a public variable:
http://www.cpearson.com/excel/TrulyGlobalVariables.htm

Here's some good insight into what ThisWorkbook is for:
http://msdn.microsoft.com/en-us/libr...ice.11%29.aspx

Normally, I use that for automating something on WorkBook_Open or
WorkBook_Close events.

--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"Phyllis" wrote:

I want to define such items as
public ws as worksheet
public rg as range

I put them in the general declarations for "This Workbook". All other
variables such as integer, string etc. are behaving as global. But not the
objects. I read some discussion about defining them as I indicated above,
but when I go to another module, it gives me the error that the name is not
defined.
Can objects be global? If so, is there a certain place they have to be
defined

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
Global Variables MM User Excel Programming 2 September 7th 08 08:09 PM
Excel loses mind clearing VBA global variables Pictou Excel Programming 2 July 22nd 08 03:05 PM
Global Variables in Excel VBA [email protected] Excel Programming 6 November 6th 06 11:21 AM
Global Variables mattsvai[_11_] Excel Programming 4 February 3rd 06 05:02 PM
Global Variables Ernst Guckel[_4_] Excel Programming 2 May 7th 05 11:10 PM


All times are GMT +1. The time now is 07:05 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"