Separator Rows

orlando606

New Member
Joined
Sep 25, 2022
Messages
10
Office Version
  1. 365
Platform
  1. Windows
Hello :)

Is there any chance one of you Excel guru's assist me creating a macro that will sort through this data in column A and insert a separator row creating a grouping of rows with the same numbers? I sorted this manually and it's slightly time consuming.

Thanks in advance.

1711541684110.png


1711541728026.png
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
As long as all the data in column A is sorted/grouped together so that like accounts are all next to each other, this code should do what you want:
VBA Code:
Sub InsertBlankRows()

    Dim lr As Long
    Dim r As Long
    
    Application.ScreenUpdating = False
    
'   Find last row in column A with data
    lr = Cells(Rows.Count, "A").End(xlUp).Row
    
'   Loop through all rows backwards
    For r = lr To 3 Step -1
'       Check to see if value in column A is different than row above
        If Cells(r, "A").Value <> Cells(r - 1, "A").Value Then
'           Insert blank line
            Rows(r).Insert
        End If
    Next r
    
    Application.ScreenUpdating = True
    
End Sub
 
Upvote 0
Solution
Joe i can't thank you enough for this code. It worked perfectly. Have a blessed day... :)
 
Upvote 0
You are welcome.
Glad I was able to help!
:)
 
Upvote 0

Forum statistics

Threads
1,215,196
Messages
6,123,575
Members
449,108
Latest member
rache47

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top