Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Variable refers to a workbook

Can I set a variable to refer to a workbook, e.g.:

Dim mywkbk as workbook

mywkbk = activeworkbook

that way if another workbook becomes active the mywkbk will refer to the
original workbook.

it just doesn't want to work for me.

I can do this:

Dim mywkbk as string

mywkbk = activeworkbook.name

then use workbooks(mywkbk) to refer to the workbook.

any way to get the first method to work in XL 2003?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 46
Default Variable refers to a workbook

Use the Set statement which assigns an object reference to a variable or
property.

Dim mywkbk as workbook
Set mywkbk = Activeworkbook
Msgbox myWkbk.Name
Msgbox myWkbk.Sheets.Count

"BlairH" wrote:

Can I set a variable to refer to a workbook, e.g.:

Dim mywkbk as workbook

mywkbk = activeworkbook

that way if another workbook becomes active the mywkbk will refer to the
original workbook.

it just doesn't want to work for me.

I can do this:

Dim mywkbk as string

mywkbk = activeworkbook.name

then use workbooks(mywkbk) to refer to the workbook.

any way to get the first method to work in XL 2003?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Variable refers to a workbook

Excellent. Thanks!

"Jackpot" wrote:

Use the Set statement which assigns an object reference to a variable or
property.

Dim mywkbk as workbook
Set mywkbk = Activeworkbook
Msgbox myWkbk.Name
Msgbox myWkbk.Sheets.Count


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
Need variable that refers to same row different column Toddomation Excel Discussion (Misc queries) 3 January 18th 10 05:50 PM
Running macro in one workbook that refers to variable in another Andyjim Excel Programming 3 January 20th 08 07:09 PM
Variable in one sub which refers to an input box in another sub. Aaron Excel Programming 1 July 1st 07 08:36 PM
Name assigned in workbook refers to range problem!!! brucemc[_16_] Excel Programming 4 June 25th 06 10:12 PM
macro button refers to prev. workbook Maja Excel Programming 1 September 13th 03 03:09 AM


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

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"