Finding duplicate values within a cell

bcmk29

Board Regular
Joined
Oct 20, 2022
Messages
55
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
In my spreadsheet, I have a column (D:D) with phone numbers mentioned. I would like to identify and highlight when a cell contains repeated/sequence numbers like 11111, 22222, 33333, or 123456.
Can we do this in VBA? Please advice.

Thanks.
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Regex (regular expressions) is good for finding patterns in strings/values, it does have a little bit of a learning curve though.

Manually coding searches to find 111, 1111, 11111, 111111, 222, 2222, etc. would be tedious at best, and adding more conditions like sequential number patterns could quickly get out of hand.
 
Upvote 0
Would something like this be any use?

Edit: I missed that you wanted vba but I'll leave this suggestion in case it might help.

22 10 29.xlsm
AB
1
212385647 
311111Check
4965894 
534567Check
Check numbers
Cell Formulas
RangeFormula
B2:B5B2=IF(OR(A2&""=REPT(LEFT(A2,1),LEN(A2)),A2&""=CONCAT(SEQUENCE(LEN(A2),,LEFT(A2,1)))),"Check","")
 
Upvote 0
Would something like this be any use?

Edit: I missed that you wanted vba but I'll leave this suggestion in case it might help.

22 10 29.xlsm
AB
1
212385647 
311111Check
4965894 
534567Check
Check numbers
Cell Formulas
RangeFormula
B2:B5B2=IF(OR(A2&""=REPT(LEFT(A2,1),LEN(A2)),A2&""=CONCAT(SEQUENCE(LEN(A2),,LEFT(A2,1)))),"Check","")
Hi Peter though I wanted a VBA code this solves my purpose. Thanks
 
Upvote 0

Forum statistics

Threads
1,223,908
Messages
6,175,305
Members
452,633
Latest member
DougMo

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