Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA Stmt Format to Get Contents of Cell in Another Book
I have two workbooks "A" & "B". I want a macro in
WorkbookA to fetch the contents of a named variable ("TestVal")in WorkbookB. For the life of me, I can't remember how to format the statement. It will look something like this: Dim X as Integer X = Workbooks("'C:\FolderNm\WorkbookB.xls'"!TestVal which, of course, is incorrect. It seems I need a range statement in there somewhere. I really would like to do this without explicitly opening WorkbookB. I have set up WorkbookB as a reference in WorkbookA's reference list, if that's any help. Any suggestions? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA Stmt Format to Get Contents of Cell in Another Book
Hi,
AFAIK you can't use VBA to read a closed workbook. But assuming the workbook is open, the following should work. Sub B() Dim r As Range Dim WB As Workbook Set WB = Workbooks("WorkbookB.xls") Set r = WB.Names("TestVal").RefersToRange Debug.Print r.Value End Sub HTH Peter Beach "SidBord" wrote in message ... I have two workbooks "A" & "B". I want a macro in WorkbookA to fetch the contents of a named variable ("TestVal")in WorkbookB. For the life of me, I can't remember how to format the statement. It will look something like this: Dim X as Integer X = Workbooks("'C:\FolderNm\WorkbookB.xls'"!TestVal which, of course, is incorrect. It seems I need a range statement in there somewhere. I really would like to do this without explicitly opening WorkbookB. I have set up WorkbookB as a reference in WorkbookA's reference list, if that's any help. Any suggestions? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Link format along with contents of another cell | Excel Worksheet Functions | |||
Format Cell contents as MM | Excel Worksheet Functions | |||
Can I format a row based on the contents of one cell? | Excel Discussion (Misc queries) | |||
If stmt and assigning a value to another cell | Excel Worksheet Functions | |||
Copying format to a new cell, w/o overwriting destination cell contents | Excel Discussion (Misc queries) |