Insert a row based on a value in column

  • Thread starter Thread starter TRexSuz
  • Start date Start date
T

TRexSuz

I am trying to insert a row in various places on a worksheet based on
the value of column "f" - short sample below:

BE92 119 6
BC109.5 111.5 6
BC87 89 6
BC72 74 6
BC72 74 6
P185.5d 199 4
P185.5d 199 4
Gx127d 127 4
Gx127d 127 4
Gx127d 127 4
R72.5 86 1
R120.5 134 1
R120 133.5 1

When the list changes from 6 to 5, or 4 etc. I want to add a space
through VB. The same when it goes from 5 to 4or3etc. and so on.
I'v tried -
Range("F3").Select
Set b = Cells.Find(What:="4", After:=ActiveCell, LookIn:=xlValues,
LookAt:= _
xlWhole, SearchOrder:=xlByColumns, SearchDirection:=xlNext,
MatchCase:= _
False).Activate
b.EntireRow.Insert
I know this is way off. Been trouble shooting for hours.
 
This will do from the last row up to row 9

Sub insertrows()
lr = Range("A65536").End(xlUp).Row
For i = lr To 9 Step -1
If Cells(i, 1) <> Cells(i + 1, 1) Then _
Cells(i + 1, 1).EntireRow.Insert
Next
End Sub
 
You may want to look at Data|subtotals.

It might be ok--and you could record a macro when you do it once if you really
need code.
 
Back
Top