As this forum is a public platform, we’ve taken steps to help protect your privacy by removing your organization’s domain name from your message. To ensure your data remains secure, we kindly recommend avoiding the inclusion of personal or organizational details such as domain names or screenshots with sensitive information in future posts.
Hi @Larry Harrison,
Thank you for your detailed information.
To get this working correctly for your situation, please follow these steps carefully:
- Press Alt + F11 to open VBA editor. Select Insert > Module > paste this script into it and close the VBA editor (script em de o duoi)
- Save the file as Macro-enabled Excel file then press Alt + F8 (or go to Developer tab > Macros) > select the macro and press Run
Note: the script date ranges are based on your sample data structure as the Account# column C and the data range from column A to column E. If you actual worksheet has different structure, please modify the ranges (those inside " ") to ensure the script can operate properly.
Sub SortByAccountAndInsertBlankRows()
Dim ws As Worksheet
Dim lastRow As Long
Dim i As Long
Set ws = ActiveSheet
'Find last used row based on Account # column C
lastRow = ws.Cells(ws.Rows.Count, "C").End(xlUp).Row
'Sort data by Account # column while still keeping header row
With ws.Sort
.SortFields.Clear
.SortFields.Add Key:=ws.Range("C2:C" & lastRow), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
.SetRange ws.Range("A1:E" & lastRow)
.Header = xlYes
.Apply
End With
'Insert blank rows between different Account # values
For i = lastRow To 3 Step -1
If ws.Cells(i, "C").Value <> ws.Cells(i - 1, "C").Value Then
ws.Rows(i).Insert Shift:=xlDown
End If
Next i
MsgBox "Data sorted by Account # and blank rows inserted.", vbInformation
End Sub

I hope the information I shared earlier was somewhat helpful in addressing your issue. If you have any further questions or updates, please don’t hesitate to share. I’m always happy to assist further if needed.
Thank you for your patience and your understanding. I look forward to continuing the conversation.