View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips Bob Phillips is offline
external usenet poster
 
Posts: 10,593
Default Finding Same Row Value

Sub Test()
Dim iLastRow As Long
Dim i As Long

iLastRow = Cells(Rows.Count, "A").End(xlUp).Row
For i = iLastRow To 2 Step -1
If Left(Application.Trim(Replace(Cells(i, "A").Value, Chr(160),
"")), 7) < _
Left(Application.Trim(Replace(Cells(i - 1, "A").Value, Chr(160),
"")), 7) Then
Rows(i).Insert
End If
Next i

End Sub

--
HTH

Bob Phillips

(replace somewhere in email address with googlemail if mailing direct)

"JN" wrote in message
...
Hi All,

I have a column that has the following numbers:

1400BAL630
1400CN2400
1400CN2500
1400CN2600
1400CN2630
1400CN2650
1400COC400
1400COC630
1400COC650
1400COC740
1400COC800
1400COC999
1400G3D400
1400G3D650
1400G3D710



I need to test the first 7 characters of the row below. If they are not

the
same, I need to insert a row and then start at the next set of 7

characters.

The end result that I am trying to achieve is:

1400BAL630

1400CN2400
1400CN2500
1400CN2600
1400CN2630
1400CN2650

1400COC400
1400COC630
1400COC650
1400COC740
1400COC800
1400COC999

1400G3D400
1400G3D650
1400G3D710


Thanks.