Livin404
Well-known Member
- Joined
- Jan 7, 2019
- Messages
- 774
- Office Version
- 365
- 2019
- Platform
- Windows
I have a listing of scheduled flights, and they are listed by departure dates and time. There may be days there are no flights (see image Oct 21 for example). I would like it to insert a date 21 Oct 2020 0000. Just one date, it doesn't have to match the previous or following days numbers. Once that is done I'm hoping to insert "NO DEPARTURES". In Column A that newly inserted row should be blank except the date which was added. I did find a code which has got the general idea date insertion. See below.
VBA Code:
Sub insertdate()
Dim rr As Date
Dim x As Long, rw As Long, diff As Long
Range("D300").End(xlUp).Select
With Selection
rw = .Row
rr = Int(.Value)
.Offset(1, 0).Select
End With
Selection = Now()
diff = Int(Selection.Value - rr)
s = InputBox("Please enter sales amount.")
Cells(rw + 1, 2) = s
If diff > 0 Then
Range(Cells(rw + 1, 1), Cells(rw + diff - 1, 1)).Select
Selection.EntireRow.Insert
For x = 1 To diff - 1
rw = rw + 1
Cells(rw, 1) = rr + 1
Cells(rw, 2) = "0"
rr = rr + 1
Next
End If
End Sub