thanks. i'll have a look into those examples.
i guess more specifically my program works if cellRange is a string "c34:e34"
however i need to refer to a named lists "SUPPLIER_TOTAL_CHARGE" and "TOTAL_PROFIT" which is in the closed worksheet and refers to cell c34 and E34 respectively.
Is there any way to set the value of cellRange so that it refers to a named list instead of entering the range manually?
something like cellRange = Range("TOTAL_SUPPLIER_CHARGE").Address & ":" & Range("TOTAL_PROFIT").Address
Sub GetValuesFromAClosedWorkbook(fPath As String, _
fName As Variant, sName, cellRange As String, counter As Long)
Dim rownumber As Long
Debug.Print fPath, fName, sName, cellRange, counter
rownumber = 4 + counter
With ActiveSheet.Range("C" & rownumber & ":E" & rownumber)
.FormulaArray = "='" & fPath & "\[" & fName & "]" _
& sName & "'!" & cellRange _
.Value = .Value
End With
End Sub
Bookmarks