counting cells in a column if the row above has a certain value in another column

polgy

New Member
Joined
Jul 25, 2018
Messages
5
Hi everyone,

I need a formula to count the number of cells in a column only containing a certain value, if they are in the row immediately below the row containing another value in another column.

Here is an example (columns A, B, rows 1-6):

AB
1x
2y
3xy
4xy
5
6xy

<tbody>
</tbody>

I want to count how many y in B are in a row below the row of a cell containing x in A;
in the above example, this number is 2: the y on row 2 follows the x in row 1, and the y in row 4 follows the x in row 3.

Thanks!
 
@jtakw I actually tried both formulas, but instead of copying and pasting the intervals, I redefined them on my worksheet :p

Hope it is clear now: I will test this further, but I think both formulas work well for my problem!

Thanks again to both of you!!
 
Upvote 0

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Well, I'm/We're glad that it's working for you.

Yes, the formulas will work consistently for your requirements.

There's no contradiction in your request, I believe sheetspread was just perplexed when you said our formulas weren't working and was looking for clarification.

If you have a "large" dataset, I do recommend my COUNTIFS formula over the SUMPRODUCT as it's less resource intensive.

Again, I'm glad it's working for you, post back if you need more assistance.

And You're Welcome, Welcome to the forum.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,343
Messages
6,124,400
Members
449,156
Latest member
LSchleppi

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