I need some help with copying data from one excel which is a daily report to a monthly report. Is there a possibility if you insert a date in one cell to recognize the date and paste the data to the needed range for the proper date?
So far, I have made the macro to copy the data for one date (let's say the 1st of a month), and I can't think of a solution that doesn't involve 31 button macros referring to each day of the month.
Sub Insert_Daily_Report()
Dim OpenBook As Workbook
Dim Report As Workbook
Dim FileToOpen As Variant
Set Report = ThisWorkbook
FileToOpen = Application.GetOpenFilename(Title:="Insert the daily report", FileFilter:="Excel Files
(*.xlsm*), *xlsm*")
If FileToOpen <> False Then
Set OpenBook = Application.Workbooks.Open(FileToOpen)
OpenBook.Sheets("Daily_Sheet1").Range("E4:AB4").Copy
Set Report = ActiveWorkbook
ThisWorkbook.Worksheets("Monthly_Sheet1").Activate
ActiveSheet.Range("E4").Select
ActiveSheet.PasteSpecial Link:=True
Set OpenBook = ActiveWorkbook
OpenBook.Sheets("Daily_Sheet1").Range("E10:AB10").Copy
Set Report = ActiveWorkbook
ThisWorkbook.Worksheets("Monthly_Sheet1").Activate
ActiveSheet.Range("E39").Select
ActiveSheet.PasteSpecial Link:=True
OpenBook.Close False
End If
End Sub
Also, I think that the marco is not switching between the two workbooks well - the pasted data is not the right data (I have checked the ranges, they are ok)