MS Excel: insert a row automatically if the content in a cell is <> that in cell of the last row?

Hi @Anita I’m suggesting you a bttr on, has more variety,, try this,, ☺

Sub InsertRowsAsValueChange()

Dim Rng As Range
Dim WorkRng As Range

On Error Resume Next

xTitleId = “Insert Range”

Set WorkRng = Application.Selection

Set WorkRng = Application.InputBox( “Range” , xTitleId, WorkRng.Address, Type:=8)
Application.ScreenUpdating = False

For i = WorkRng.Rows.Count To 2 Step -1

If WorkRng.Cells(i, 1).Value <> WorkRng.Cells(i – 1, 1).Value Then

WorkRng.Cells(i, 1).EntireRow.Insert
End If


Application.ScreenUpdating = True

End Sub

NB :When you run this will show inputbox to insert data range. 😁

Hope this help u.

Browse More Popular Posts

Leave a Comment