Hi There. I have data with date ranges, but there are missing dates and need all dates to be included in the file output e.g.
In this example, I need to create rows above the 8th of July (Column C) to add 1st to 7th of July.
It also needs to replace the information in row 2, for Columns A,B,D and E when inserting the rows above.
This will only be when the first record (in row 2) does not equal the 1st of the month.
So, basically, I need the code to validate if C2 is the 1st of the month, and if not, insert the number of rows required to let row 2 equal the 1st of the month.
I managed to solve inserting rows below e.g. adding 9 and 10 July as additional rows BETWEEN rows 2 and 3 using this code :
Dim x as long
Dim MyColumn as String
Dim LastRow as Long
MyColumn = "c"
For x = Cells(Rows.Count, MyColumn).End(xlUp).Row To 3 Step -1
diff = Cells(x, MyColumn) - Cells(x - 1, MyColumn)
If diff > 1 Then
Rows(x).Resize(diff - 1).Insert
End If
Next x
LastRow = Cells(Cells.Rows.Count, MyColumn).End(xlUp).Row
For Each Area In Range(MyColumn & "3:" & MyColumn & LastRow).SpecialCells(xlCellTypeBlanks).Areas
Area(1).Offset(-1).AutoFill Destination:=Range(Area(1).Offset(-1).Resize(Area.Rows.Count + 1).Address)
Next
Any help will be appreciated.
Thanks
In this example, I need to create rows above the 8th of July (Column C) to add 1st to 7th of July.
It also needs to replace the information in row 2, for Columns A,B,D and E when inserting the rows above.
This will only be when the first record (in row 2) does not equal the 1st of the month.
So, basically, I need the code to validate if C2 is the 1st of the month, and if not, insert the number of rows required to let row 2 equal the 1st of the month.
I managed to solve inserting rows below e.g. adding 9 and 10 July as additional rows BETWEEN rows 2 and 3 using this code :
Dim x as long
Dim MyColumn as String
Dim LastRow as Long
MyColumn = "c"
For x = Cells(Rows.Count, MyColumn).End(xlUp).Row To 3 Step -1
diff = Cells(x, MyColumn) - Cells(x - 1, MyColumn)
If diff > 1 Then
Rows(x).Resize(diff - 1).Insert
End If
Next x
LastRow = Cells(Cells.Rows.Count, MyColumn).End(xlUp).Row
For Each Area In Range(MyColumn & "3:" & MyColumn & LastRow).SpecialCells(xlCellTypeBlanks).Areas
Area(1).Offset(-1).AutoFill Destination:=Range(Area(1).Offset(-1).Resize(Area.Rows.Count + 1).Address)
Next
Any help will be appreciated.
Thanks