In sheet INPUT, rows of data for week schedule gets inputted. Multiple rows per day is possible. Column A contains the dates of the original week of the schedule. When the complete planning is set in the INPUT sheet (lets say 15 rows by 10 columns of data) a macro can be run which copies the planning to the OUTPUT sheet and creates it for a full year. Therefore I'm coding VBA to copy the block of data and paste it beneath the previous week and update the dates by 7 days.
I'm having difficulties with DateAdd function.
Does anyone know a good solution?
Dim i As Integer
Dim rowCount As Long
Dim columnCount As Long
Sheets("OUTPUT").Select
Sheets("OUTPUT").Cells.Clear
Sheets("INPUT").Select
rowCount = Sheets("INPUT").Range("A6", Sheets("INPUT").Range("A6").End(xlDown)).Rows.Count - 1
columnCount = Sheets("INPUT").Range("A5", Sheets("INPUT").Range("A5").End(xlToRight)).Columns.Count - 1
Range("A5").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Sheets("OUTPUT").Select
Range("A1").Select
ActiveSheet.Paste
For i = 1 To 51
Range("A" & Rows.Count).End(xlUp).Select
Range(Selection, Selection.Offset(-rowCount, columnCount)).Copy
Range("A" & Rows.Count).End(xlUp).Select
ActiveCell.Offset(1, 0).PasteSpecial
Range("A" & Rows.Count).End(xlUp).Select
Range(Selection, Selection.Offset(-rowCount, 0)).Value = DateAdd("d", 7, Range(Selection, Selection.Offset(-rowCount, 0)).Value)
Next i