MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Add a row at each change in time


Posted by Lori on January 07, 2002 1:35 PM

I have another question about times. I have a list of appointment times. Is there a way for me to have Excel insert a row (or 2) at each change in times? Thanks. Lori


Posted by Tom Dickinson on January 07, 2002 6:37 PM

Lori:
I posted the following for someone requesting a similar need. You should be able to modify it for yours.

Highlight the first cell you want compared in the column where you have the text to compared. then run the following macro. This will put in 1 blank row (if there isn't one already), and continue down the column until it encounters 2 blank cells. At that point it will end.

Sub Macro1()
Do Until ActiveCell = Empty And ActiveCell.Offset(1) = Empty
If ActiveCell <> ActiveCell.Offset(1) And ActiveCell <> Empty And ActiveCell.Offset(1) <> Empty Then
ActiveCell.Offset(1).EntireRow.Insert
ActiveCell.Offset(2).Select
Else
ActiveCell.Offset(1).Select
End If
Loop
End Sub

Posted by Lori on January 08, 2002 9:41 AM

Thanks Tom; worked great!