ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Need Macro- Insert rows based on dates and copy info from that row (https://www.excelbanter.com/excel-discussion-misc-queries/260801-need-macro-insert-rows-based-dates-copy-info-row.html)

Katerinia

Need Macro- Insert rows based on dates and copy info from that row
 
I need a macro
that will insert a number of blank rows
based on the number of months between a start and end date
and then copy the information in the reference row to the new blank rows.

repeat for each start and end date sequence.

The records are over 8,350.. so ill also need some idea how to get it to
stop when it fills the worksheet so i can transfer those into another workbook


Bob Phillips[_4_]

Need Macro- Insert rows based on dates and copy info from that row
 
Assuming start date in column A, end date in column B

Public Sub ProcessData()
Dim i As Long
Dim LastRow As Long
Dim NumRows As Long

With ActiveSheet

LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
For i = LastRow To 1 Step -1

NumRows = .Cells(i, "B").Value2 - .Cells(i, "A").Value2
If NumRows 0 Then

.Rows(i + 1).Resize(NumRows).Insert
.Rows(i).Copy .Cells(i + 1, "A").Resize(NumRows)
End If
Next i
End With

End Sub


--

HTH

Bob

"Katerinia" wrote in message
...
I need a macro
that will insert a number of blank rows
based on the number of months between a start and end date
and then copy the information in the reference row to the new blank rows.

repeat for each start and end date sequence.

The records are over 8,350.. so ill also need some idea how to get it to
stop when it fills the worksheet so i can transfer those into another
workbook





All times are GMT +1. The time now is 12:00 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com