View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
RB Smissaert RB Smissaert is offline
external usenet poster
 
Posts: 2,452
Default Insert Row Macro based on contents of two columns

How about simply:

If Cells(i - 1, 2) < Cells(i, 2) And Cells(i - 1, 1) < Cells(i, 1)
Then _
Cells(i, 1).Resize(1, 1).EntireRow.Insert

RBS

"5elpep" wrote in message
ups.com...
Good morning group.

The below is a very useful macro to insert rows where the contents of
column B change.
How might it be modified so that it inserts rows where the contents of
columns A and B change?

Sub InsertRow_At_Change()
Dim i As Long
With Application
.Calculation = xlManual
.ScreenUpdating = False
End With
For i = Cells(Rows.Count, 2).End(xlUp).Row To 2 Step -1
If Cells(i - 1, 2) < Cells(i, 2) Then _
Cells(i, 1).Resize(1, 1).EntireRow.Insert
Next i
With Application
.Calculation = xlAutomatic
.ScreenUpdating = True
End With
End Sub

Many thanks