count a block of numbers, and calculate block size

ekalavya

New Member
Joined
Mar 5, 2014
Messages
31
Hi everyone,

I have approximately 100 rows (samples) and 4000 columns (Trait1, 2, ... n) that look like below.

Input
Size0.10.30.50.60.911.12.2
SampleTrait1Trait2Trait3Trait4Trait5Trait6Trait7Trait8
A00011000
B11101111
C00111000
D00000011

<tbody>
</tbody>

For each sample, I want to scan the block of numbers, and report the size of the block (first row). For example, Sample A has first block of 0s of size 0.5 (0.5 - 0.0); second block of 1s of size 0.3 (0.9 - 0.6); and third block of 0s of size 1.2 (2.2 - 1.0).

Desired output
SampleBlock1Size1Block2Size2Block3Size3
A00.510.301.2
B10.50011.3
C00.310.401.2
D0111.1

<tbody>
</tbody>

Please note that for sample B, which as only 1 zero, the size is also zero as it is not a block. Therefore, if there's a value by itself (count of 1), then the size should be zero.

I hope someone here can help me with this as my data size is pretty big and it is killing me to scan it by color-coding the spreadsheet.

Thank you for your generous help, as always.
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Why is it not 0.4 (0.5 - 0.1)?

Counting for this data begins with 0 so the first 'size' is value - 0.

Actually, in hindsight, I should have listed 0 as the first value in the 'Size' row to avoid confusion.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,631
Messages
6,120,640
Members
448,974
Latest member
DumbFinanceBro

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