I use this all the time to get the data from a closed file
Function GetDataFromClosed(Path, File, Sheet, Address)
Dim strAddress As String
Dim cl
strAddress = Path & File & Sheet
Worksheets(Sheet).UsedRange.Clear
With Worksheets(Sheet).Range(Address)
On Error Resume Next
.FormulaR1C1 = "=IF('" & strAddress & "'!RC="""",NA(),'" & strAddress & "'!RC)"
.SpecialCells(xlCellTypeFormulas, xlErrors).Clear
On Error GoTo 0
.Value = .Value
End With
End Function
Sub Call_Get_Data()
Dim strTemp As String
Dim strName As String
strTemp = "A1:H10000" ''range of cells to copy from/to (change as required)
strName = "[" & "workbook_to_load_from.xls" & "]"
strTemp = GetDataFromClosed("C:\Temp\", strName, "WorkSheet_To_Copy_From", strTemp)
ActiveSheet.Cells.Range("A1:H10000").Font.Bold = False''this tidies up the worksheet after the import function
Columns.AutoFit
End Sub
Bookmarks