How to automatically insert a blank row after a group of data based on column selected by the User - i.e. active cell

PHOTO EMBED

Wed Sep 08 2021 04:49:30 GMT+0000 (Coordinated Universal Time)

Saved by @cnewnham #vba

Sub AddBlankRows_ColumnSelectedbyUser() 'How to automatically insert a blank row after a group of data based on column selected by the User - i.e. active cell
'The Cells(row,column) command allows you to stipulate which cell a range to to extend from "MyRow = ActiveCell.Row", "MyCol = ActiveCell.Column". Both these commands allow the program to identify what row or column the mouse is on
Dim iRow As Integer, iCol As Integer
Dim oRng As Range

Set oRng = Cells(1, ActiveCell.Column) 'Selects first cell e.g. "A1" in selected column to enable the function to perform task) ' Column to review for group of data

iRow = oRng.Row
iCol = oRng.Column

Do
'
If Cells(iRow + 1, iCol) <> Cells(iRow, iCol) Then
    Cells(iRow + 1, iCol).EntireRow.Insert Shift:=xlDown
    iRow = iRow + 2
Else
    iRow = iRow + 1
End If
'
Loop While Not Cells(iRow, iCol).Text = ""
'
End Sub
content_copyCOPY