Aug 31, 2007 #1 griffitd Programmer Aug 20, 2002 189 GB Hi I'm after a line of code to make a variable equal to a cell value in another excel file. i.e. somrthing like the following: sValue = excelfile.xls.cells(r1c1) Hope you can help thanks
Hi I'm after a line of code to make a variable equal to a cell value in another excel file. i.e. somrthing like the following: sValue = excelfile.xls.cells(r1c1) Hope you can help thanks
Aug 31, 2007 #2 Rofeu Technical User Apr 13, 2005 500 NL Hi, Code: sValue = Application.Worksbooks("YourWB.xls").Cells(1,1).Value Cheers, Roel Upvote 0 Downvote
Aug 31, 2007 Thread starter #4 griffitd Programmer Aug 20, 2002 189 GB Thanks for the reply when I run the code i get "subscript out of range error" Dave Upvote 0 Downvote
Aug 31, 2007 #5 rmikesmith Technical User Apr 29, 2002 1,215 US Dave, Whatever you have in place of 'YourWB.xls' is not the name of an open workbook; i.e. does not match any open workbooks. Also, when you get that corrected, there needs to be a worksheet reference between the Workbooks and Cells identifiers. Example Code: sValue = Application.Worksbooks("YourWB.xls").Worksheets("Sheet1").Cells(1,1).Value Regards, Mike Upvote 0 Downvote
Dave, Whatever you have in place of 'YourWB.xls' is not the name of an open workbook; i.e. does not match any open workbooks. Also, when you get that corrected, there needs to be a worksheet reference between the Workbooks and Cells identifiers. Example Code: sValue = Application.Worksbooks("YourWB.xls").Worksheets("Sheet1").Cells(1,1).Value Regards, Mike
Aug 31, 2007 Thread starter #6 griffitd Programmer Aug 20, 2002 189 GB Mike I don't reallly want to open the spreadsheet. Does it need to be open? Dave Upvote 0 Downvote
Aug 31, 2007 Thread starter #7 griffitd Programmer Aug 20, 2002 189 GB Mike/Rofeu The following works if I have the excel file open: svalue = Application.Workbooks(sFileName1).Worksheets("Portrait").Cells(1, 1).Value Can i get this to work without having it open. Thanks Upvote 0 Downvote
Mike/Rofeu The following works if I have the excel file open: svalue = Application.Workbooks(sFileName1).Worksheets("Portrait").Cells(1, 1).Value Can i get this to work without having it open. Thanks
Aug 31, 2007 #8 rmikesmith Technical User Apr 29, 2002 1,215 US Dave, See John Walkenbach's article on retrieving cell values from closed workbooks (uses the old Excel macro language): http://www.j-walk.com/ss/excel/tips/tip82.htm Regards, Mike Upvote 0 Downvote
Dave, See John Walkenbach's article on retrieving cell values from closed workbooks (uses the old Excel macro language): http://www.j-walk.com/ss/excel/tips/tip82.htm Regards, Mike
Aug 31, 2007 Thread starter #9 griffitd Programmer Aug 20, 2002 189 GB Looks Good Thanks for the help Upvote 0 Downvote