helpneeded2
Board Regular
- Joined
- Jun 25, 2021
- Messages
- 110
- Office Version
- 365
- Platform
- Windows
I am not really experienced with VBA, and am trying to copy from data from a source sheet in a different Excel file, and paste it via a button executed macro into the current spreadsheet.
Based on examples I have seen, I have been able to do it this way:
However, since the "OLG Sheet.xlsm" will always be renamed with the date as part of the name, (i.e.: OLG Sheet 2022-09-21.xlsm), I instead need to target the current sheet that the macro is launching from. Could someone please tell me how I can switch the focus back to main sheet, regardless of its name.
Based on examples I have seen, I have been able to do it this way:
VBA Code:
Sub Obtain_OLG_Data()
Workbooks.Open ("G:\Branch1\Department2\Unit\Protected Document\OLG Master Lists\OLG MASTER TO DATE.xlsx")
Workbooks("OLG MASTER TO DATE.xlsx").Worksheets("OLG MASTER CSV V10").Range("A1:AP260000").Copy
Workbooks("OLG Sheet.xlsm").Worksheets("OLG_MASTER").Range("A2").PasteSpecial Paste:=xlPasteValues
End Sub
However, since the "OLG Sheet.xlsm" will always be renamed with the date as part of the name, (i.e.: OLG Sheet 2022-09-21.xlsm), I instead need to target the current sheet that the macro is launching from. Could someone please tell me how I can switch the focus back to main sheet, regardless of its name.