# COUNTIF using formula based on ROW and COLUMN

#### nicknicknickandnick

##### New Member
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?

### Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

##### MrExcel MVP
something like this?

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

#### nicknicknickandnick

##### New Member
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.)

##### MrExcel MVP
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? Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

### Forum statistics

1,164,423
Messages
5,837,152
Members
430,479
Latest member
mamush200 ### 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.

### Which adblocker are you using?    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

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