Consulting

Results 1 to 2 of 2

Thread: Check whether numbers are sequential?

  1. #1

    Check whether numbers are sequential?

    Hi, can someone please assist? Column A contains the project number, and the number begins with AB210001, AB210002, so on. I'd like to write some codes in VBA to check whether the project numbers in column A are sequential. The system that I pull the report from sometimes misses some projects.

  2. #2
    This is my little take on your problem.

    Sub AshCount()
    Dim StartRow As Integer
    Dim EndRow As Integer
    Dim CompareNum As String
    Dim x As Integer
    
    StartRow = 1
    EndRow = Range("A9999").End(xlUp).Row
    
    CompareNum = Right(Range("A1").Value, 6)
    
    For x = StartRow To EndRow
        If Right(Range("A" & x).Value, 6) <> CompareNum Then
        MsgBox "Missing Reference between rows " & x - 1 & " and " & x
        Range("A" & x - 1).Select
        Exit Sub
        End If
    CompareNum = CompareNum + 1
    Next x
    
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •