cozzagiorgi
New Member
- Joined
- Jun 27, 2018
- Messages
- 41
Hi
I am using this code to copy data from a closed workbook:
It works fine as long as the line:
is equal in size as the size of the named range in mydata AND it is at the same spot as the original named range.
How can I put mydata in other ranges and adapt the
to the size of the original named range?
I hope I am clear, english isn't my mother tongue. Ask away if necessary. Thanks!
I am using this code to copy data from a closed workbook:
Code:
Sub GetDataFromClosedBook()
Dim mydata As String
'data location & range to copy
mydata = "='F:\filepath\filename.xlsm'!NamedRange" '<< change as required
'link to worksheet
With ThisWorkbook.Worksheets(1).Range("B10:M23")
.Value = mydata
'convert formula to text
.Value = .Value
End With
End Sub
It works fine as long as the line:
Code:
With ThisWorkbook.Worksheets(1).Range("B10:M23")
is equal in size as the size of the named range in mydata AND it is at the same spot as the original named range.
How can I put mydata in other ranges and adapt the
Code:
Range("B10:M23")
I hope I am clear, english isn't my mother tongue. Ask away if necessary. Thanks!