COUNTIF using formula based on ROW and COLUMN

nicknicknickandnick

New Member
Joined
Apr 29, 2002
Messages
29
As part of a mathematical exploration, I have made a square set of cells which show "A", "B", and "C" according to how each of the cell's row and column numbers are related to a third number (which is entered by the user). I won't go into detail about the math that determines if a cell shows A, B, or C because I have no trouble there.

I want to make formulas that don't just simply count how many cells in a range have A, B, or C (I know how to do that). Rather, I want to make, for example, a formula that counts how many A cells there are in a range, but only counts the A cells for the cells whose column number divided by row number is a result less than 1. (I also want formulas to count such cells with results equal to 1 and greater than 1.)

If I used COUNTIF($A$1:$J$10,AND("A",COLUMN()/ROW()<1)), the result is zero because the column and row functions are referencing the cell that the COUNTIF function is in rather than each of the cells in the desired range. Because the column and row functions only refer to the cell that the COUNTIF function is in, I can't count the cells I want.

Any formula ideas?
 

Some videos you may like

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.

PaddyD

MrExcel MVP
Joined
May 1, 2002
Messages
14,234
something like this?

=SUMPRODUCT(((COLUMN(A1:C3)/ROW(A1:C3))<1)*(A1:C3="a"))

paddy
 

nicknicknickandnick

New Member
Joined
Apr 29, 2002
Messages
29
Based on a little testing I did, I think that might work, although I am not familiar with how SUMPRODUCT operates so I am clueless right now about how it works, if it does work.

I'll now mention complications that I left out earlier: I am actually basing the comparison on (ROW()+1)/2 rather than just ROW(), because I have every second row of cells with other information that doesn't affect the counts I want to do anyway. (Also, I am using letters other than "A", "B", and "C", which I put here for clarity.)

So, let's see if I understand some of these parts so I can modify it at will:
=SUMPRODUCT(((COLUMN(A1:C3)/ROW(A1:C3))<1)*(A1:C3="a"))

If I wanted to modify that formula to count the cells in the range of A1 to F11 whereby the counted cells contain the text "Y" and those cells have a column number and row number such that COLUMN()/((ROW()+1)/2))<1, then the formula would be:

=SUMPRODUCT(((COLUMN($A$1:$F$11)/((ROW($A$1:$F$11)+1)/2))<1)*($A$1:$F$11="Y"))

Would that be correct?

(I put $ in so I could copy the formula to other cells and modify the formula without affecting the specific range of cells considered for counting.)
 

PaddyD

MrExcel MVP
Joined
May 1, 2002
Messages
14,234
Bugger! Do you still have the text available? Prepared to post it up in a new thread so we can continue to refer to it?

Paddy
 

Watch MrExcel Video

Forum statistics

Threads
1,122,481
Messages
5,596,396
Members
414,063
Latest member
N_Bates

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