I have an excel sheet in workbook1 and I want to use VBA to copy the rows of data in that sheet according to the day(Sunday,Monday...) but to another workbook (Days) which has a separate sheet for each day.
All the examples I found were copying from one workbook to only one sheet in another workbook
Could you please help me with this?
I am using this code but when I tried to repeat it for the other days I get confused especially when to use open & save methods
Sub myTest()
Dim LastRow As Integer, i As Integer, erow As Integer
LastRow = ActiveSheet.Range("A" & Rows.Count).End(xlUp).Row
For i = 2 To LastRow
If Cells(i, 2).Value = "Sunday" Then
Range(Cells(i, 1), Cells(i, 7)).Select
Selection.Copy
Workbooks.Open Filename:="C:\Users\User1\Documents\Days.xlsx"
Worksheets("Sunday").Select
erow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
ActiveSheet.Cells(erow, 1).Select
ActiveSheet.Paste
ActiveWorkbook.Save
ActiveWorkbook.Close
Application.CutCopyMode = False
End If
Next i
End Sub