PDA

View Full Version : Getting information from excel



mwork
01-26-2008, 10:27 PM
Hi, I want to be able to get one excel file to get a value from a cell in another excel file. How would I do this? Could someone write some sample code of how this would be done?
Thanks,
Matt.

mikerickson
01-26-2008, 11:20 PM
=[Workbook2.xls]Sheet2!$B$36

or
Workbooks("Workbook2.xls").Sheets("Sheet2").Range("B36")

If I knew more about where and why you want the data, I could give a less generic answer.

mwork
01-26-2008, 11:51 PM
Wouldn't it need to know the file location like C:\Docs\filename?
I have a template excel file that I use to do a lot of calculations. I copy the file and make a copy for each customer. Some things change like prices of products, so now I have to go back and change it on each seperate customer file. I would like to make the template refer back to a single excel file that holds the price information so that when I make copies of the file they all refer to the same place. Then I can just update the one excel file.

mikerickson
01-27-2008, 12:12 AM
I don't know the technique of looking at a closed workbook. If you make a cell reference, Excel will prompt you to open the needed file.

Aussiebear
01-27-2008, 03:49 AM
Try this link to find how to get data from a closed workbook.

http://www.exceltip.com/excel_tips/Files,_Workbook,_and_Worksheets_in_VBA/203.html