Reading the contents of a Cell from a closed Workbook

Lorgach

New Member
Joined
Jul 6, 2005
Messages
16
Hi All,
I am new to writing Excel VB Macros so I hope this is not too silly a question.
I have looked at the archived Q & A's and can only find answers to this that involve quite a few lines of Code.
Is there any way to read the contents of a single Cell from a CLOSED Workbook that you know the name and location of, by using a single line of Code?
eg. Read the Data in Cell 'A1' on Sheet 'Sheet1' in Workbook 'Test-1.xls'.

I have tried to modify the Code that I got from
http://j-walk.com/ss/excel/tips/tip82.htm

VariXXX = ExecuteExcel4Macro("'C:\TestFolder\[TestWorkBook.xls]TestSheet'!$A$1")

I have also tried other variations of this but with no success.
Any help would be appreciated.

Thanks in Advance
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
This worked for me:

Code:
Sub Test()
    VariXXX = ExecuteExcel4Macro("'C:\TestFolder\[TestWorkBook.xls]TestSheet'!R1C1")
    MsgBox VariXXX
End Sub

Note the R1C1 style.
 
Upvote 0
Thanks very much Andrew.
It seems so simple now when I see it.
I had tried everything except the 'R1C1' instead of 'A1" for the Cell location.
I suppose knowledge will come with experience.
Best Regards.
 
Upvote 0

Forum statistics

Threads
1,203,138
Messages
6,053,717
Members
444,681
Latest member
Nadzri Hassan

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top