View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Claus Busch Claus Busch is offline
external usenet poster
 
Posts: 3,872
Default Need to flag the lead ID of any contiguous ID's from a sorted list of ID's.

Hi J.P.,

Am Wed, 8 Oct 2014 12:22:50 -0700 (PDT) schrieb JeanPierre Charron:

For instance :
ID Flag Comment
111 x is a lead
112
113
115 X Complex Case involving a similar numeric & alphanumeric
115A
123 x is isolated
250A x is a lead
250B
300A1 X is a lead
300A2


If there are no other "special" cases try:

Sub SetFlag()
Dim LRow As Long
Dim rngC As Range

With ActiveSheet
LRow = .Cells(Rows.Count, 1).End(xlUp).Row
Range("B2") = "x"

For Each rngC In .Range("A3:A" & LRow)
If Len(rngC) = 5 And Right(rngC, 1) = "1" Then
rngC.Offset(, 1) = "x"
ElseIf Right(rngC, 1) = "A" And Int(Left(rngC, 3)) _
< rngC.Offset(-1, 0) Then
rngC.Offset(, 1) = "x"
ElseIf Len(rngC.Offset(1, 0)) = Len(rngC) + 1 _
And InStr(rngC.Offset(1, 0), rngC) Then
rngC.Offset(, 1) = "x"
ElseIf IsNumeric(rngC) And Not _
IsNumeric(rngC.Offset(-1, 0)) Then
rngC.Offset(, 1) = "x"
End If
Next
End With

End Sub



Regards
Claus B.
--
Vista Ultimate / Windows7
Office 2007 Ultimate / 2010 Professional