change in message sequence

Chris1981

New Member
Joined
Mar 26, 2019
Messages
1
If I have a long list of numbers, how do I find where that list of numbers is not consecutive. How do I show when the sequence changes from 5 to 8 and from 9 to12?

1
2
3
4
5
8
9
12
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Assuming your numbers start in cell A1, put this formula in cell B2 and copy it down to the bottom of your data...

=IF(A2-A1>1,"<==","")
 
Upvote 0
Here's a simple macro that will highlight the relevant cell(s) in yellow:

Code:
Option Explicit
Sub Macro1()

    Dim lngLastRow As Long
    Dim lngMyRow As Long
    
    Application.ScreenUpdating = False

    lngLastRow = Cells(Rows.Count, "A").End(xlUp).Row
    
    'Works backwards from the last Row in Col. A to Row 2. Change to suit.
    For lngMyRow = lngLastRow To 2 Step -1
        If Val(Range("A" & lngMyRow)) - 1 <> Val(Range("A" & lngMyRow - 1)) Then
            Range("A" & lngMyRow).Interior.Color = RGB(255, 255, 0)
        Else
            Range("A" & lngMyRow).Interior.Color = xlNone
        End If
    Next lngMyRow
    
    Application.ScreenUpdating = True

End Sub

Robert
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,176
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top