Inserting lines according to number of days, adjusting date
Try this:
Sub InsertRows()
Dim Startdate As Date
Dim EndDate As Date
Dim Gap
Dim Prow As Integer
Startdate = Range("A2").Value
EndDate = Range("B2").Value
Gap = EndDate - Startdate
Prow = 4
If Gap = 0 Then
Else
For i = 0 To Gap
Let Startdate = Startdate + i
Let Prow = Prow + 1
Cells(Prow, 1) = Startdate
Cells(Prow, 2) = Startdate
Cells(Prow, 4) = Range("D2")
Startdate = Range("A2").Value
Next
End If
End Sub
Just change the Prow to your starting row. It also assumes that the
Startdate, Enddate line starts in A2. You could curcumvent this by
giving the cells named ranges and then you could move them anywhere,
then just sub these in for Range("A2").value.
Hope this helps you out.
Stopher
|