Need to flag the lead ID of any contiguous ID's from a sorted list of ID's.
Hi J.P.,
Am Thu, 9 Oct 2014 17:55:34 -0700 (PDT) schrieb JeanPierre Charron:
Extending my test list with real ID's resulted in new cases not resolved as expected.
unfortunately you did not flag the new example. I hope I saw all cases.
If not, please post the list with the expected flags.
With different cases it is better to check the special cases first and
the simple cases at last. The length also differs in alphanumeric
values.
Sub SetFlag()
Dim LRow As Long
Dim rngC As Range
Dim flag As Boolean
With ActiveSheet
LRow = .Cells(Rows.Count, 1).End(xlUp).Row
Range("B2") = "x"
For Each rngC In .Range("A3:A" & LRow)
flag = False
If Not IsNumeric(rngC) And Right(rngC, 1) = "1" Then
flag = True
ElseIf Right(rngC, 1) = "A" And Int(Left(rngC, 3)) _
< rngC.Offset(-1, 0) Then
flag = True
ElseIf Len(rngC.Offset(1, 0)) = Len(rngC) + 1 _
And InStr(rngC.Offset(1, 0), rngC) Then
flag = True
ElseIf IsNumeric(rngC) And Not _
IsNumeric(rngC.Offset(-1, 0)) Then
flag = True
ElseIf IsNumeric(rngC) And Len(rngC) _
< Len(rngC.Offset(-1, 0)) Then
flag = True
End If
If flag = True Then rngC.Offset(, 1) = "x"
Next
End With
End Sub
Regards
Claus B.
--
Vista Ultimate / Windows7
Office 2007 Ultimate / 2010 Professional
|