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

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
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,220,965
Messages
6,157,119
Members
451,399
Latest member
alchavar

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