Countif until blank cell reached repeatedly in sheet

Valkyrie_ride

New Member
Joined
Oct 3, 2017
Messages
7
Dear all

Would like to seek help to Countif a range of cells within tables (that are not formatted as tables due to design needs) in an Excel sheet.
The problem is that the tables do not have the same amount of rows, so if we drag the formula down, it will not work. I thought of using OFFSET or INDEX MATCH, but I am not sure how to make use those to achieve what I want.

This is what I hoped to achieve in the 'To calculate' column. You can see that there are two separate tables and I want the countifs to start from the non-blank cells, stop at a blank cell, then re-start from the next non-blank cell.

I would appreciate it if anyone can guide me on this!

[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Levels[/TD]
[TD]Data[/TD]
[TD]To calculate[/TD]
[/TR]
[TR]
[TD]B1[/TD]
[TD]3[/TD]
[TD]COUNTIF(B2:B6,">0.39")*0.5[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]3[/TD]
[TD]COUNTIF(B2:B6,">0.39")*0.5[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]5[/TD]
[TD]COUNTIF(B2:B6,">0.39")*0.5[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]8[/TD]
[TD]COUNTIF(B2:B6,">0.39")*0.5[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]12[/TD]
[TD]COUNTIF(B2:B6,">0.39")*0.5[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]B1[/TD]
[TD]5[/TD]
[TD]COUNTIF(B9:B10,">0.39")*0.5[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]5[/TD]
[TD]COUNTIF(B9:B10,">0.39")*0.5[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
 

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.
I can't help feeling I've over-complicated this!


Book1
ABC
1LevelsDataTo calculate
2B132.5
3132.5
4252.5
5382.5
64122.5
7
8
9B151
10151
Sheet1
Cell Formulas
RangeFormula
C2{=IF($A2="","",COUNTIF(OFFSET($B2,MAX(IF(ROW($A$1:$A$3000)),IF($A$1:$A$3000="Levels",ROW($A$1:$A$3000),IF($A$1:$A$3000="",ROW($A$1:$A$3000)))))-ROW()+1,0,MIN(IF(ROW($A$1:$A$3000)>ROW(),IF($A$1:$A$3000="",ROW($A$1:$A$3000))))-ROW()-(MAX(IF(ROW($A$1:$A$3000)),IF($A$1:$A$3000="Levels",ROW($A$1:$A$3000),IF($A$1:$A$3000="",ROW($A$1:$A$3000)))))-ROW()+1),1),">0.39")*0.5)}
Press CTRL+SHIFT+ENTER to enter array formulas.


WBD
 
Upvote 0
Question:
Is the first value of each table in the Levels column always "B1"?

M.
 
Upvote 0
I don't know what version you're using. Or if a helper column is OK.

Helper, C2 and down =C1+NOT(AND(LEN(B1),LEN(B2)))
then in D2 and down =COUNTIFS(C:C,C2,B:B,">0.39")*0.5

OK?
 
Upvote 0
Hi @Fazza, I am looking into your solution: thank you!

However, I would like to understand what is the use of the helper column: what does it do?

thanks for explaining to a beginner!
 
Upvote 0
Thank you for the explanation!

I tried this but it didn't work... what I am looking for is a result like this:
[table="width: 500, class: grid"]
[tr]
[td]Levels[/td]
[td]Data[/td]
[td]Calculation[/td]
[/tr]
[tr]
[td]B1[/td]
[td]3[/td]
[td]2.5[/td]
[/tr]
[tr]
[td]1[/td]
[td]3[/td]
[td]2.5[/td]
[/tr]
[tr]
[td]2[/td]
[td]5[/td]
[td]2.5[/td]
[/tr]
[tr]
[td]3[/td]
[td]8[/td]
[td]2.5[/td]
[/tr]
[tr]
[td]4[/td]
[td]12[/td]
[td]2.5[/td]
[/tr]
[tr]
[td][/td]
[td][/td]
[td][/td]
[/tr]
[tr]
[td][/td]
[td][/td]
[td][/td]
[/tr]
[tr]
[td]B1[/td]
[td]5[/td]
[td]1[/td]
[/tr]
[tr]
[td]1[/td]
[td]5[/td]
[td]1[/td]
[/tr]
[/table]

Using your way, I got 3.5 all the way; not sure if I did anything wrong...
 
Upvote 0
Hi,

For me, it is not always B1. For example, in the example above, it's B2 and B9 respectively.

I'm asking about the first value in column A (Levels) for each table (group of cells), not the first cell in column B.
Is it always a text ("B1")?

M.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,169
Members
453,021
Latest member
Justyna P

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