Macro, insert row

donniedorian

Board Regular
Joined
May 27, 2015
Messages
133
Hello,

I need a new row if a2<>a3 = insert new row in a4, so the new row should be right underneath a3, for the all data in the a:a column
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Hi donniedorian,

Try the below code

Code:
Sub AddRows()
For x = ActiveSheet.Range("A" & Rows.Count).End(xlUp).Row To 2 Step -1
    If Cells(x, 1) <> Cells(x - 1, 1) Then Rows(x).Rows.Insert
Next x
End Sub
 
Upvote 0

Forum statistics

Threads
1,216,545
Messages
6,131,282
Members
449,641
Latest member
paulabrink78

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