Inserting Row

mizunobill

New Member
Joined
Feb 5, 2004
Messages
13
I have a very large spreadsheet that I need to add rows to. I would think a macro would work but I am kind of new to this. In column A I have a list of account numbers when the number changes I need a new row, is there a way to do this?

Column A
175X105SELK
175X105SELK
20X14KMWA70
20X14KMWA70
225X13KM210
225X13KM210
24X16 FD755
24X16 FD755
25X14SELLICK
25X14SELLICK
25X14SELLICK
25X14SELLICK
25X14SELLICK
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Code:
Sub Insert_rows()
Dim i As Long
Dim Last_Row As Long

Application.ScreenUpdating = False

With Sheets("Sheet1") 'change sheet name as appropriate

    Last_Row = .Range("A" & Rows.Count).End(xlUp).Row
    
    For i = Last_Row To 2 Step -1
    
        If .Cells(i, 1).Value <> .Cells(i - 1, 1).Value Then .Cells(i, 1).EntireRow.Insert
    
    Next i

End With


Application.ScreenUpdating = True

End Sub
 
Upvote 0
If you add

Option Compare text 'Goes in very first line - outside of the sub

then the string comparison is not case sensetive-not sure if that matters
 
Upvote 0

Forum statistics

Threads
1,223,964
Messages
6,175,657
Members
452,664
Latest member
alpserbetli

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