Forum Discussion
KennyMcG
Aug 18, 2023Copper Contributor
insert space between date range
I have a row of information ( travel log ) over a set of dates downloaded from an app, how can I insert a space between the dates in a specific column ? see below I need a space between 18th and 19th...
OliverScheurich
Aug 18, 2023Gold Contributor
An alternative could be this code. You can change the data in column A from this:
| 20.04.2023 17:01 |
| 20.04.2023 16:02 |
| 20.04.2023 14:40 |
| 20.04.2023 13:33 |
| 20.04.2023 13:01 |
| 20.04.2023 08:06 |
| 19.04.2023 14:25 |
| 19.04.2023 14:14 |
| 19.04.2023 13:46 |
| 19.04.2023 13:40 |
| 18.04.2023 06:05 |
| 18.04.2023 02:52 |
| 18.04.2023 01:26 |
| 17.04.2023 14:52 |
| 17.04.2023 09:21 |
| 06.04.2023 16:19 |
| 06.04.2023 07:40 |
to this by running the macro:
| 20.04.2023 17:01 |
| 20.04.2023 16:02 |
| 20.04.2023 14:40 |
| 20.04.2023 13:33 |
| 20.04.2023 13:01 |
| 20.04.2023 08:06 |
| 19.04.2023 14:25 |
| 19.04.2023 14:14 |
| 19.04.2023 13:46 |
| 19.04.2023 13:40 |
| 18.04.2023 06:05 |
| 18.04.2023 02:52 |
| 18.04.2023 01:26 |
| 17.04.2023 14:52 |
| 17.04.2023 09:21 |
| 06.04.2023 16:19 |
| 06.04.2023 07:40 |
The code inserts a blank cell each time the day changes no matter if days are consecutive.
Sub insert_blank()
Dim i, j As Long
j = Range("A" & Rows.Count).End(xlUp).Row
For i = j To 2 Step -1
If Day(Cells(i, 1)) = Day(Cells(i - 1, 1)) Then
Else
Cells(i, 1).Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
End If
Next i
End Sub