Need Macro for Insert Row on Unique Value

xbrianx

New Member
Joined
Dec 2, 2010
Messages
24
VoG, I have a macro you supplied in a different thread:

Sub InsRow()
Dim LR As Long, i As Long
LR = Range("A" & Rows.Count).End(xlUp).Row
For i = LR To 2 Step -1
If Range("A" & i).Value <> Range("A" & i - 1).Value Then Rows(i).Insert
Next i
End Sub


However, this is inserting a row ABOVE and BELOW where the value in column 'A' changes. Can you give me the macro to insert 2 rows ABOVE where the value in column 'A' changes? Thanks.
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
To be specific, column 'A' looks like this:

A
(blank)
(blank)
B
(blank)
C
(blank)
(blank)
(blank)
D
(blank)
(blank)
E
(blank)
(blank)
(blank)
(blank)
(blank)
F
(blank)
G
(blank)
(blank)

I have a lot of data in columns in B-N, and I want to but in two blank rows above where there is a NEW value in column 'A'
 
Upvote 0
Still need help with macro to insert row ABOVE unique value

Removing the "-" sign on row4 4 of the macro before the "1" does nothing:

Sub InsRow()
Dim LR As Long, i As Long
LR = Range("A" & Rows.Count).End(xlUp).Row
For i = LR To 2 Step
-1
If Range("A" & i).Value <> Range("A" & i - 1).Value Then Rows(i).Insert
Next i
End Sub


PLEASE HELP!!!!!!!! Thx.
 
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,730
Members
452,939
Latest member
WCrawford

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