TaskMaster
Board Regular
- Joined
- Oct 15, 2020
- Messages
- 75
- Office Version
- 365
- 2016
- Platform
- Windows
Hi all,
Hoping that someone can help me with the following. I have a spreadsheet called Weekly Report with tabs named days of the week and spreadsheets containing data sharing the same name. E.g copying data from a workbook called Monday into the tab called Monday in my weekly report file. I want do something similar for product codes however to do this for each code would take some time. Is there a way that I could automate it so that if the tabs in my weekly report spreadsheet share the same as the file in a selected folder it would copy the data from that spreadsheet into the tabs listed. Thank you in advance.
Hoping that someone can help me with the following. I have a spreadsheet called Weekly Report with tabs named days of the week and spreadsheets containing data sharing the same name. E.g copying data from a workbook called Monday into the tab called Monday in my weekly report file. I want do something similar for product codes however to do this for each code would take some time. Is there a way that I could automate it so that if the tabs in my weekly report spreadsheet share the same as the file in a selected folder it would copy the data from that spreadsheet into the tabs listed. Thank you in advance.
VBA Code:
Sub Data()
Dim Folder As String
Dim Monday As String
Dim Tuesday As String
Dim Wednesday As String
Dim Thursday As String
Dim Friday As String
Folder = "C:\Users\Flow\Desktop\Test\"
'Monday
Workbooks.Open Filename:=Folder & "Monday.xlsx"
Range("A2:BF2000").Copy
Windows("Weekly Report.xlsm").Activate
Sheets("Monday").Range("A2").PasteSpecial Paste:=xlPasteValues
'Tuesday
Workbooks.Open Filename:=Folder & "Tuesday.xlsx"
Range("A2:BF2000").Copy
Windows("Weekly Report.xlsm").Activate
Sheets("Tuesday").Range("A2").PasteSpecial Paste:=xlPasteValues
'Wednesday
Workbooks.Open Filename:=Folder & "Wednesday.xlsx"
Range("A2:BF2000").Copy
Windows("Weekly Report.xlsm").Activate
Sheets("Wednesday").Range("A2").PasteSpecial Paste:=xlPasteValues
'Thursday
Workbooks.Open Filename:=Folder & "Thursday.xlsx"
Range("A2:BF2000").Copy
Windows("Weekly Report.xlsm").Activate
Sheets("Thursday").Range("A2").PasteSpecial Paste:=xlPasteValues
'Friday
Workbooks.Open Filename:=Folder & "Friday.xlsx"
Range("A2:BF2000").Copy
Windows("Weekly Report.xlsm").Activate
Sheets("Friday").Range("A2").PasteSpecial Paste:=xlPasteValues
End Sub