Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Need variable that refers to same row different column | Excel Discussion (Misc queries) | |||
Running macro in one workbook that refers to variable in another | Excel Programming | |||
Variable in one sub which refers to an input box in another sub. | Excel Programming | |||
Name assigned in workbook refers to range problem!!! | Excel Programming | |||
macro button refers to prev. workbook | Excel Programming |