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.
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.

Russ At Index

Well-known Member
Joined
Sep 23, 2002
Messages
685
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
 

Forum statistics

Threads
1,141,665
Messages
5,707,699
Members
421,524
Latest member
Bharath99

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
Top