Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ed Ed is offline
external usenet poster
 
Posts: 65
Default Set objects at module level?

I have a module with several Subs. All the Subs will refer to the
same objects. I know how to Dim the object references at the top of
the module, but then I have to Set them in each Sub. Is there a way
to set workbook, worksheet and range objects for the entire module?

Ed

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 535
Default Set objects at module level?

Hi Ed,

I have a module with several Subs. All the Subs will refer to the
same objects. I know how to Dim the object references at the top of
the module, but then I have to Set them in each Sub. Is there a way
to set workbook, worksheet and range objects for the entire module?


Setting them in one sub will set them for all, so make sure your entry
sub checks whether the object variables have been set, if not, set
them.

Regards,

Jan Karel Pieterse
Excel MVP
http://www.jkp-ads.com
Member of:
Professional Office Developer Association
www.proofficedev.com

  #3   Report Post  
Posted to microsoft.public.excel.programming
Ed Ed is offline
external usenet poster
 
Posts: 65
Default Set objects at module level?

Hi, Jan.

Setting them in one sub will set them for all, so make sure your entry
sub checks whether the object variables have been set, if not, set
them.


And all this time, I thought the objects vanished with every End Sub!
So if I'm doing a lot of Subs in THisWorkbook module, I can DIm and
Set objects in a Workbook_Open sub and they will live in that module
as long as the workbook is open?

Ed


On May 7, 6:42 am, Jan Karel Pieterse wrote:
Hi Ed,

I have a module with several Subs. All the Subs will refer to the
same objects. I know how to Dim the object references at the top of
the module, but then I have to Set them in each Sub. Is there a way
to set workbook, worksheet and range objects for the entire module?


Setting them in one sub will set them for all, so make sure your entry
sub checks whether the object variables have been set, if not, set
them.

Regards,

Jan Karel Pieterse
Excel MVPhttp://www.jkp-ads.com
Member of:
Professional Office Developer Associationwww.proofficedev.com



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 535
Default Set objects at module level?

Hi Ed,

So if I'm doing a lot of Subs in THisWorkbook module, I can DIm and
Set objects in a Workbook_Open sub and they will live in that module
as long as the workbook is open?


Exactly. As long as you don't press "End" on a runtime error...

Regards,

Jan Karel Pieterse
Excel MVP
http://www.jkp-ads.com
Member of:
Professional Office Developer Association
www.proofficedev.com

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
Assign Value to Module Level Variable monir Excel Programming 21 March 23rd 05 03:05 AM
use of module level variables TxRaistlin Excel Programming 2 March 3rd 05 10:41 PM
Declaring array constants at module level Microsoft Forum Excel Programming 2 January 24th 05 06:31 PM
referencing at module level Mark[_36_] Excel Programming 1 March 1st 04 01:24 PM
module-level variable lifetime Jessie[_2_] Excel Programming 0 July 30th 03 09:31 PM


All times are GMT +1. The time now is 01:39 PM.

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"