List of telephone numbers and need to highlight sequential ranges

Picillo

New Member
Joined
Jan 14, 2021
Messages
10
Office Version
  1. 365
Platform
  1. Windows
I'm working on a spreadsheet that has a column of telephone numbers. There 1700 numbers and I need to filter/highlight out what numbers are in ranges or produce a list in a different column or worksheet.

So I need something like this.

1610686040000.png


I'd prefer for a list of the ranges in a different column, but highlighting will do as well.

I have tried the Conditional Formatting method and it doesn't appear to work.

Any help would be greatly appreciated.

Thank you,
 
Try this:
VBA Code:
Sub a1158545b()
'https://www.mrexcel.com/board/threads/list-of-telephone-numbers-and-need-to-highlight-sequential-ranges.1158545/
Dim i As Long, j As Long, n As Long
Dim va, vb
Dim flag As Boolean

n = Range("A" & Rows.Count).End(xlUp).Row + 1
va = Range("A1:A" & n)
ReDim vb(1 To UBound(va, 1), 1 To 2)
flag = False

For i = 2 To UBound(va, 1) - 1

    If va(i, 1) + 1 = va(i + 1, 1) Then
        vb(i, 1) = va(i, 1)
        vb(i + 1, 1) = va(i + 1, 1)
        If flag = False Then j = i: flag = True
    Else
        flag = False

    End If
    If i > 2 Then
        If flag = False And va(i - 1, 1) + 1 = va(i, 1) Then vb(j, 2) = va(i, 1)
    End If
Next

'result in col B
Range("B1").Resize(UBound(vb, 1), 2) = vb

End Sub

Book1 (version 1).xlsb
ABC
1data
2112
322
46
58
610
7121214
81313
91414
1017
1120
12242425
132525
Sheet1
Thank you so much to both of you. You made a project really easy for me. You guys are the best.
 
Upvote 0

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
You're welcome, glad to help & thanks for the feedback. :)
 
Upvote 0

Forum statistics

Threads
1,214,987
Messages
6,122,618
Members
449,092
Latest member
amyap

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