Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 116
Default Duplicate Digits

Could there be a solution, without conditional formatting,
of being able to

Count duplicate or triplicate etc. digits within a single cell

For example
Data Count
A1 B1
5555 4
1112 3
1122 2
1234 0
1101 3


I have tried this formula with some success

=IF(MOD(A1,1111)=0,"4",IF(MOD(A1,111)=0,"3",IF(MOD (A1,11)=0,"2",))
for one Cell A1

Thanks





  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 538
Default Duplicate Digits

smandula wrote:

Could there be a solution, without conditional formatting,
of being able to

Count duplicate or triplicate etc. digits within a single cell

For example
Data Count
A1 B1
5555 4
1112 3
1122 2
1234 0
1101 3


I have tried this formula with some success

=IF(MOD(A1,1111)=0,"4",IF(MOD(A1,111)=0,"3",IF(MOD (A1,11)=0,"2",))
for one Cell A1


If VBA is acceptable, then this works (for your sample data anyway). Put this
in a module:
Function MostRepeats(what)
Dim chk1 As Long, chk2 As Long, chk3 As Long
Dim digits(9) As Long
chk1 = what
While chk1 0
chk2 = chk1 Mod 10
chk1 = chk1 \ 10
digits(chk2) = digits(chk2) + 1
If digits(chk2) chk3 Then chk3 = digits(chk2)
Wend
If chk3 1 Then MostRepeats = chk3
End Function

....and call it like this:
A B
1 5555 =MostRepeats(A1)
2 1112 =MostRepeats(A2)
3 1122 =MostRepeats(A3)
4 1234 =MostRepeats(A4)
5 1101 =MostRepeats(A5)

--
The key to being a genius is timing.
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 538
Default Duplicate Digits

I wrote:

smandula wrote:

Could there be a solution, without conditional formatting,
of being able to

Count duplicate or triplicate etc. digits within a single cell

For example
Data Count
A1 B1
5555 4
1112 3
1122 2
1234 0
1101 3


I have tried this formula with some success

=IF(MOD(A1,1111)=0,"4",IF(MOD(A1,111)=0,"3",IF(MOD (A1,11)=0,"2",))
for one Cell A1


If VBA is acceptable, then this works (for your sample data anyway). Put
this in a module:

[snip]

Should've mentioned that what I posted assumes positive whole numbers...

--
Stupid clockwork reject.
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 116
Default Duplicate Digits

Thanks!

That is a beautiful piece of code.

It works very well.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do you change single digits to recognized double digits? Evil with a K[_2_] Excel Worksheet Functions 5 April 3rd 23 02:29 PM
VBA write macro change column with 3 number digits to 4 digits the James C[_2_] Excel Discussion (Misc queries) 3 January 25th 10 03:12 PM
number 12 digits to 15 digits mehdy-e Excel Discussion (Misc queries) 5 November 13th 09 04:43 PM
VBA to delete Duplicate Records (1 column), before which, non-duplicate data merged into remaining row [email protected] Excel Programming 6 August 20th 09 02:40 AM
How to customize number to 10 digits including 2 digits after deci Carina Excel Worksheet Functions 3 September 20th 07 02:50 AM


All times are GMT +1. The time now is 05:55 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"