This code will extract the sequential numbers of form AB001, AB002 etc. from the first 10 rows of column 1 and put them in column 4. You should be able to adapt it to the number format you're using, then delete column 1 when you're finished.
Sub SequencerMacro()
Dim i As Integer
Dim j As Integer
Dim intCount As Integer
Dim intValue As Integer
Dim intStart As Integer
intCount = 1
For i = 1 To 10
'find first number in sequence
If Left(Cells(i, 1).Value, 2) = "AB" Then
'get numeric part
intValue = CInt(Right(Cells(i, 1).Value, 3))
'copy value to new column
Cells(intCount, 4).Value = Cells(i, 1).Value
'increment counters
intCount = 2
intStart = i
Exit For
End If
Next i
'now find the rest of the values and copy as necessary
For i = intStart To 10
If Left(Cells(i, 1).Value, 2) = "AB" Then
If CInt(Right(Cells(i, 1).Value, 3)) = intValue + 1 Then
Cells(intCount, 4).Value = Cells(i, 1).Value
intCount = intCount + 1
intValue = intValue + 1
End If
End If
Next i
End Sub
Hope this helps!
!--removed tag-->
Enter your message below
Sign in or Join us (it's free).