Need Formula

CARBOB

Well-known Member
Joined
Jun 6, 2005
Messages
1,870
I need a formula in Column G that will count the individual digits in Columns B:F in this order
1,2,3,4,5,6,7,8,9,0.

Example 6 8 15 23 25 1210210100
1234567890
Excel Workbook
ABCDEFG
72/25/2011681523251210210100
82/24/2011151333352040200000
92/23/201112273032351330101001
Sheet1
Excel 2007
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
This will return the number of ones
Code:
=LEN(B7&C7&D7&E7&F7)-LEN(SUBSTITUTE(B7&C7&D7&E7&F7,"1",""))
It would be a long formula but you could wrap that in a =concatenate() and each argument would be the formula above with the relevant digit in place of "1" in the substitute()
 
Upvote 0
It works and thank you. Maybe someone will come up with a shorter version.
Excel Workbook
BCDEFG
7681523251210210100
8151333352040200000
Sheet1
Excel 2007
Cell Formulas
RangeFormula
G7=CONCATENATE(LEN(B7&C7&D7&E7&F7)-LEN(SUBSTITUTE(B7&C7&D7&E7&F7,"1",""))&LEN(B7&C7&D7&E7&F7)-LEN(SUBSTITUTE(B7&C7&D7&E7&F7,"2",""))&LEN(B7&C7&D7&E7&F7)-LEN(SUBSTITUTE(B7&C7&D7&E7&F7,"3",""))&LEN(B7&C7&D7&E7&F7)-LEN(SUBSTITUTE(B7&C7&D7&E7&F7,"4",""))&LEN(B7&C7&D7&E7&F7)-LEN(SUBSTITUTE(B7&C7&D7&E7&F7,"5",""))&LEN(B7&C7&D7&E7&F7)-LEN(SUBSTITUTE(B7&C7&D7&E7&F7,"6",""))&LEN(B7&C7&D7&E7&F7)-LEN(SUBSTITUTE(B7&C7&D7&E7&F7,"7",""))&LEN(B7&C7&D7&E7&F7)-LEN(SUBSTITUTE(B7&C7&D7&E7&F7,"8",""))&LEN(B7&C7&D7&E7&F7)-LEN(SUBSTITUTE(B7&C7&D7&E7&F7,"9",""))&LEN(B7&C7&D7&E7&F7)-LEN(SUBSTITUTE(B7&C7&D7&E7&F7,"0","")))
G8=CONCATENATE(LEN(B8&C8&D8&E8&F8)-LEN(SUBSTITUTE(B8&C8&D8&E8&F8,"1",""))&LEN(B8&C8&D8&E8&F8)-LEN(SUBSTITUTE(B8&C8&D8&E8&F8,"2",""))&LEN(B8&C8&D8&E8&F8)-LEN(SUBSTITUTE(B8&C8&D8&E8&F8,"3",""))&LEN(B8&C8&D8&E8&F8)-LEN(SUBSTITUTE(B8&C8&D8&E8&F8,"4",""))&LEN(B8&C8&D8&E8&F8)-LEN(SUBSTITUTE(B8&C8&D8&E8&F8,"5",""))&LEN(B8&C8&D8&E8&F8)-LEN(SUBSTITUTE(B8&C8&D8&E8&F8,"6",""))&LEN(B8&C8&D8&E8&F8)-LEN(SUBSTITUTE(B8&C8&D8&E8&F8,"7",""))&LEN(B8&C8&D8&E8&F8)-LEN(SUBSTITUTE(B8&C8&D8&E8&F8,"8",""))&LEN(B8&C8&D8&E8&F8)-LEN(SUBSTITUTE(B8&C8&D8&E8&F8,"9",""))&LEN(B8&C8&D8&E8&F8)-LEN(SUBSTITUTE(B8&C8&D8&E8&F8,"0","")))
 
Upvote 0
Try...

G7, confirmed with CONTROL+SHIFT+ENTER, and copied down:

=SUM(MMULT(LEN(B7:F7)-LEN(SUBSTITUTE(B7:F7,{1;2;3;4;5;6;7;8;9;0},"")),TRANSPOSE(COLUMN(B7:F7)^0))*10^{9;8;7;6;5;4;3;2;1;0})
 
Upvote 0
Try...

G7, confirmed with CONTROL+SHIFT+ENTER, and copied down:

=SUM(MMULT(LEN(B7:F7)-LEN(SUBSTITUTE(B7:F7,{1;2;3;4;5;6;7;8;9;0},"")),TRANSPOSE(COLUMN(B7:F7)^0))*10^{9;8;7;6;5;4;3;2;1;0})


Much neater!!! Thanks Domenic.
 
Upvote 0

Forum statistics

Threads
1,224,524
Messages
6,179,308
Members
452,904
Latest member
CodeMasterX

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