inserting blank rows in a data spreadsheet

sharonk

New Member
Joined
Oct 6, 2006
Messages
2
:rolleyes:
Help.
I have created a data spreadsheet with numerous columns. I have sorted this spreadsheet by P/N. I would like for Excel to automatically insert a blank row each time this field (P/N) changes.
 

Some videos you may like

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)

Russ At Index

Well-known Member
Joined
Sep 23, 2002
Messages
665
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
  2. MacOS
Hi Sharonk, Welcome To The Board,

Try copying this into VB.

Sub InsertRows()
Dim rng As Range
Set rng = Range("A1")
While rng.Value <> ""
If rng.Value <> rng.Offset(1).Value Then
rng.Offset(1).EntireRow.Insert
Set rng = rng.Offset(1)
End If
Set rng = rng.Offset(1)
Wend
End Sub


HTH

Russ
 

Watch MrExcel Video

Forum statistics

Threads
1,114,038
Messages
5,545,672
Members
410,697
Latest member
srishtijain0708
Top