Forum Discussion
Cto06
Feb 23, 2024Copper Contributor
Excel dates
Hello I have a quick question. I have data that I need to organize and I want to do it by the dates my employees work. But when I download the data it’s not formatted the way I need. For example, the...
HansVogelaar
Feb 23, 2024MVP
I hope that the point after 1/2. etc. is a typo.
Run this macro:
Sub InsertDates()
Const firstrow = 1 ' first data row; change as needed
Dim r As Long
Dim lastrow As Long
Application.ScreenUpdating = False
lastrow = Range("A" & Rows.Count).End(xlUp).Row
r = lastrow
Do
If Range("A" & r).Value > Range("A" & r - 1).Value + 1 Then
Range("A" & r).EntireRow.Insert
Range("A" & r).Value = Range("A" & r + 1).Value - 1
Else
r = r - 1
End If
Loop Until r = 1
Application.ScreenUpdating = False
End Sub