Check if a cell contains same digits

kelly mort

Well-known Member
Joined
Apr 10, 2017
Messages
2,169
Office Version
  1. 2016
Platform
  1. Windows
Hi,

I am looking for a way to verify if a cell say A1 contains same digits like 1111, 2222, etc.

The Len will always be 4.

Thanks in advance
 
Great!!!!


One last request then I take a nap:)

How will I verify format like:
0011
0022
....
1100
1122
1133
....
2200
2211
2233
....

Code:
MsgBox Range("A1").Text = String(4, Left(Range("A1").Text, 1))

As the above was dealing with the whole 4 for same characters, here I want compare the first two characters for sameness then move to the last two for sameness. If both cases are true then the msgbox shows. Eg 1122 not 1123
 
Upvote 0

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
MsgBox Range("A1").Text = String(2, Left(Range("A1").Text, 1)) & String(2, Right(Range("A1").Text, 1))
 
Upvote 0
Does a number like 5555 where all the digits are the same qualify as being True under this request?

Thanks Rick for pointing that out. I was not able to think to that level. In that case I want it turn false .

So I think I can use the solution at post # 24 to check that. Better still I am open to more elegant options.
 
Upvote 0
Thanks Rick for pointing that out. I was not able to think to that level. In that case I want it turn false .
If you are always checking only cell A1 and no other, you can use this somewhat compact code line to do your latest check...

MsgBox [AND(LEFT(A1)=MID(A1,2,1),MID(A1,3,1)=RIGHT(A1),LEFT(A1)<>RIGHT(A1))]
 
Upvote 0
If you are always checking only cell A1 and no other, you can use this somewhat compact code line to do your latest check...

MsgBox [AND(LEFT(A1)=MID(A1,2,1),MID(A1,3,1)=RIGHT(A1),LEFT(A1)<>RIGHT(A1))]
Okay I appreciate that

More knowledge for me to imbibe:)
 
Upvote 0

Forum statistics

Threads
1,223,240
Messages
6,170,951
Members
452,368
Latest member
jayp2104

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