ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   pulling information from a closed workbook (revised) (https://www.excelbanter.com/excel-programming/385087-pulling-information-closed-workbook-revised.html)

edluver

pulling information from a closed workbook (revised)
 
i am sorry, the code in the original post is not correct, it should be this:

Function GetValuesFromAClosedWorkbook(fPath As String, _
fName As String, sName, cellRange As String)

With ActiveSheet.Range(cellRange)
.FormulaArray = "='" & fPath & "\[" & fName & "]" _
& sName & "'!" & cellRange
.Value = .Value
End With
End Function


Sub test1()
GetValuesFromAClosedWorkbook "E:", "Book1.xls", "Sheet1", "A4:J4"
End Sub

sorry for the confusion.

Tom Ogilvy

pulling information from a closed workbook (revised)
 
Ron de Bruin posted this in response to your previous post:

Maybe this
http://www.rondebruin.nl/copy7.htm

But for a whole sheet I think you can better open the workbook and copy the
sheet to your workbook


--
Regards,
Tom Ogilvy


"edluver" wrote:

i am sorry, the code in the original post is not correct, it should be this:

Function GetValuesFromAClosedWorkbook(fPath As String, _
fName As String, sName, cellRange As String)

With ActiveSheet.Range(cellRange)
.FormulaArray = "='" & fPath & "\[" & fName & "]" _
& sName & "'!" & cellRange
.Value = .Value
End With
End Function


Sub test1()
GetValuesFromAClosedWorkbook "E:", "Book1.xls", "Sheet1", "A4:J4"
End Sub

sorry for the confusion.



All times are GMT +1. The time now is 09:20 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com