Automatically Inserting Blank Rows

Pibsandsquibs

New Member
Joined
Aug 18, 2021
Messages
17
Office Version
  1. 365
Platform
  1. Windows
Hello

As most spreadsheets I have a long list of data, some of the data in column A repeats itself for a mixture of 1, 2 or 3 rows then it has a new number that again could repeat itself for 1,2 or 3 rows.

Is there anyway to make my spreadsheet clearer that I can insert a blank line automatically where the number in column A changes.

Current Example

120820
120820
120821
120823
120823
120823

Thanks
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Hello, something like this (where A1:C6 represents your dataset and A1:A6 are those numbers)?

Excel Formula:
=LET(
data,A1:C6,
category,A1:A6,
DROP(DROP(REDUCE("",UNIQUE(category),LAMBDA(x,y,IFNA(VSTACK(x,FILTER(data,category=y),""),""))),1),-1))
 
Upvote 0
Paste this code into the Sheet object of your VBA Project.
VBA Code:
Option Explicit

Sub InsertBlank()
Dim rng As Range, cell As Range
Dim i As Integer
Set rng = Range(Cells(1, 1), Cells(Sheet1.UsedRange.Rows.Count, 1))
For i = rng.Rows.Count To 1 Step -1
    If i = 1 Then Exit Sub
    If Not rng.Cells(i, 1).Value = rng.Cells(i - 1, 1).Value Then
        rng.Cells(i, 1).EntireRow.Insert
    End If
Next i
End Sub
 
Upvote 0
Try.
VBA Code:
Dim Lr&, T&, S$
Dim M
Lr = Range("A" & Rows.Count).End(xlUp).Row
M = Filter(Evaluate("Transpose(If(A2:A" & Lr - 1 & "<>A3:A" & Lr & ",""A""&Row(A3:A" & Lr & "),false))"), False, False)
For T = UBound(M) To 0 Step -1
S = S & "," & M(T)
If Len(S) > 240 Or T = 0 Then Range(Mid(S, 2)).EntireRow.Insert: S = ""
Next T
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,811
Messages
6,181,082
Members
453,021
Latest member
Justyna P

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