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,
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
My worksheet layout is given below.

1610687250921.png


Select Cell A2 and do conditional formatting as shown below.

The formula is

=IF(OR(A1=A2-1,A1=A1048576+1),TRUE,"")

1610687333325.png

Then use format painter to apply the same formatting to other cells.

Kind regards

Saba
 
Upvote 0
My worksheet layout is given below.

View attachment 29844

Select Cell A2 and do conditional formatting as shown below.

The formula is

=IF(OR(A1=A2-1,A1=A1048576+1),TRUE,"")

View attachment 29845
Then use format painter to apply the same formatting to other cells.

Kind regards

Saba

Thank you very much. I figured out that my cells were not formatted as numbers which why nothing was happening. I appreciate your solution.
 
Upvote 0
Does anyone know how to list the ranges in another column or worksheet?
 
Upvote 0
Another option:
VBA Code:
Sub a1158545a()
'https://www.mrexcel.com/board/threads/list-of-telephone-numbers-and-need-to-highlight-sequential-ranges.1158545/
Dim i As Long
Dim va, vb

va = Range("A1", Cells(Rows.Count, "A").End(xlUp))
ReDim vb(1 To UBound(va, 1), 1 To 1)

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)
    End If
    
Next

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

End Sub

Book1 (version 1).xlsb
AB
1data
211
322
46
58
610
71212
81313
91616
101717
1119
122424
132525
Sheet1
 
Upvote 0
You're welcome, glad to help & thanks for the feedback. :)
 
Upvote 0
Another option:
VBA Code:
Sub a1158545a()
'https://www.mrexcel.com/board/threads/list-of-telephone-numbers-and-need-to-highlight-sequential-ranges.1158545/
Dim i As Long
Dim va, vb

va = Range("A1", Cells(Rows.Count, "A").End(xlUp))
ReDim vb(1 To UBound(va, 1), 1 To 1)

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)
    End If
   
Next

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

End Sub

Book1 (version 1).xlsb
AB
1data
211
322
46
58
610
71212
81313
91616
101717
1119
122424
132525
Sheet1
Do you know of way produce the same results but to have the beginning of a range in the B column and the end of the range in the C column. e.g.,

1610690260604.png


Thanks ahead of time for any assistance.
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,215,491
Messages
6,125,107
Members
449,205
Latest member
ralemanygarcia

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