mrdowjones
New Member
- Joined
- Feb 5, 2019
- Messages
- 2
Hi,
I have the below code that opens and copies data from a closed workbook to the active workbook.
I would like to change two things which I cannot figure out in the final piece of the code:
1: Worksheets("00161"): I would like this to be dynamic, so that I can enter 00161 to a cell in my active destination workbook and change it on demand.
2: Range("A1").Formula: I would like to copy the entire used range in this worksheet.
I have failed at attempts on both of the above. Does anyone have any ideas?
Many thanks!
I have the below code that opens and copies data from a closed workbook to the active workbook.
Code:
Sub FetchData()
Dim src As Workbook
Set src = Workbooks.Open("G:\Managers\Existing Managers\Equities\Data Management\Monthly Manager Research Notes\PA_OUTPUT\FACTSET_MANAGER_DATA.xlsx", True, True)
ThisWorkbook.Activate
Worksheets("holdings_data").Range("a1").Formula = src.Worksheets("00161").Range("A1").Formula
src.Close
End Sub
Code:
src.Worksheets("00161").Range("A1").Formula
1: Worksheets("00161"): I would like this to be dynamic, so that I can enter 00161 to a cell in my active destination workbook and change it on demand.
2: Range("A1").Formula: I would like to copy the entire used range in this worksheet.
I have failed at attempts on both of the above. Does anyone have any ideas?
Many thanks!