unknownymous
Board Regular
- Joined
- Sep 19, 2017
- Messages
- 249
- Office Version
- 2016
- Platform
- Windows
Hi Guys,
I have a macro-add in where it will attached the files on another already open workbook. However, whenever I run the codes, the files are being attached to the macro add-in and not on the open workbook.
I have this section that I think I need to tweak the codes. Otherwise, feel free to let me know other ways.
Note: The open workbook has a word "Master" on its filename (as the name varies based on subject like Math Master 2018).
Any thoughts will be appreciated.
I have a macro-add in where it will attached the files on another already open workbook. However, whenever I run the codes, the files are being attached to the macro add-in and not on the open workbook.
I have this section that I think I need to tweak the codes. Otherwise, feel free to let me know other ways.
Code:
Private Sub OpenFile(filepath)
Dim sh, wb As Workbook, wbMe As Workbook
Set wbMe = ThisWorkbook
Set wb = Workbooks.Open(filepath)
For Each sh In wb.Sheets
sh.Copy after:=wbMe.Sheets(wbMe.Sheets.Count)
Next sh
wb.Close False
End Sub
Note: The open workbook has a word "Master" on its filename (as the name varies based on subject like Math Master 2018).
Any thoughts will be appreciated.
Last edited by a moderator: