0

I have a column with numbers like:

66234 
666575 
66567 
665687 
66090 
66000

And I need to write code that detects when "77" + SomeNumber starts. And insert empty row between new numbers.

What command I should use?

Shai Rado
  • 33,032
  • 6
  • 29
  • 51
  • Range("").EntireRow.Insert – Andreas Dec 09 '16 at 08:11
  • `Rows(x).Insert Shift:=xlDown` where `x` is the row number. Could you clarify this line: **"detects when 77 + SomeNumber starts"** –  Dec 09 '16 at 08:25
  • look at http://stackoverflow.com/questions/15417544/how-to-automatically-insert-a-blank-row-after-a-group-of-data /// just use Left(Cells(iRow + 1, iCol), 2) <> Left(Cells(iRow, iCol), 2) instead original – user2284877 Dec 09 '16 at 09:49

1 Answers1

0

Try the below:

Sub InsertRow()

Dim i As Long
Dim n As Long

n = Cells(Rows.Count, 1).End(xlUp).Row

For i = 1 To n
    If Left(Cells(i, 1), 2) = 77 Then
        Cells(i + 1, 1).EntireRow.Insert
    End If
Next i

End Sub

replace the 1 in n=... with the column that has the main numbers in replace the cells(i,1) and for i =1 with the respective rows to begin at :)

mojo3340
  • 534
  • 1
  • 6
  • 27