VBA - Insert Row after certain value in Column

bluelabel

Board Regular
Joined
Nov 27, 2008
Messages
73
Hello VBAers,

I have a list of data where I need to enter a blank row under the row of where a certain value appears in a column.

DogBrownCharlie
CatJack
DogBrownPrincess

<tbody>
</tbody>

In the above example, every time Brown appears, I would like to enter an empty row beneath it. The result would look like this

DogBrownCharlie
CatJack
DogBrownPrincess

<tbody>
</tbody>

Hope this makes sense.

Thank you
 

Some videos you may like

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off

Michael M

Well-known Member
Joined
Oct 27, 2005
Messages
19,237
Office Version
  1. 2013
Platform
  1. Windows
Try
Code:
Sub MM1()
 Dim lr As Long, r As Long
 lr = Cells(Rows.Count, "A").End(xlUp).Row
 For r = lr To 1 Step -1
    If Range("B" & r).Value = "Brown" Then
        Range("B" & r + 1).EntireRow.Insert
    End If
Next r
End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,108,492
Messages
5,523,260
Members
409,506
Latest member
reneekeane

This Week's Hot Topics

Top