Convert variable length txt field to Z x 1 digit numbers

Yanta

Board Regular
Joined
Aug 28, 2011
Messages
59
Where Z=length of string.

Z can be 0 to 8. Each byte of the string will be a number between 0 and 9.

I couldn't use a numeric field because 00100 becomes 100 and 00000001 becomes 1. The text string must have 1 byte for each time slot.

I referee basketball. There are between 0 and 8 games in a day. Each game is a 'time slot'. I want to count the number of times for each time slot that I call specific events, such as technical, unsportsmanlike or disqualifying fouls (each of these will be separate columns).

I then total those events in a different sheet, which is then input for a graph.

So value(mid($A5,1,1))+value(mid($A5,2,1))+value(mid($A5,3,1)) works fine if the string is 3 bytes, but if it is 0 - 2 bytes I end up with a #Value result.

Data rows start at 5. The source string is in AY. Technical in AZ, Unsportsmanlike in BA and Disqualifying in BB.

I want to Total the number of individual digits for each byte of the string. Can this be done with a single formula?

thank you.
 
Last edited:

Some videos you may like

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.

Phuoc

Active Member
Joined
Apr 29, 2016
Messages
282
Try this:

=SUMPRODUCT(--MID(A5,ROW(INDIRECT("1:"&LEN(A5))),1))

or ?

=LEN(A5)-LEN(SUBSTITUTE(A5,"1",""))
 

Yanta

Board Regular
Joined
Aug 28, 2011
Messages
59
Thanks for that. I don't think I would have figured that out. The -- threw me.
 

Watch MrExcel Video

Forum statistics

Threads
1,122,472
Messages
5,596,353
Members
414,060
Latest member
hermanseck

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
Top