Workaround for COUNTIF if diagonal cell range?

kblument

New Member
Joined
Apr 18, 2016
Messages
2
Hi,
I have a formula that uses COUNTIF that I'm trying to get to work using a diagonal range of cells (CT2,CU3,CV4,CW5....DI17). Unfortunately I've discovered that COUNTIF wont work with such a range. Even creating a named list for this diagonal range doesn't work with COUNTIF.

Here is the formula that works fine if I have a straight column as a range

=IF(AND(COUNTIF(CT2:CT17,1)<2,COUNTIF(CT2:CT17,2)<2,COUNTIF(CT2:CT17,3)<2,COUNTIF(CT2:CT17,4)<2,COUNTIF(CT2:CT17,5)<2,COUNTIF(CT2:CT17,6)<2,COUNTIF(CT2:CT17,7)<2,COUNTIF(CT2:CT17,8)<2,COUNTIF(CT2:CT17,9)<2,COUNTIF(CT2:CT17,10)<2,COUNTIF(CT2:CT17,11)<2,COUNTIF(CT2:CT17,12)<2,COUNTIF(CT2:CT17,13)<2,COUNTIF(CT2:CT17,14)<2,COUNTIF(CT2:CT17,15)<2,COUNTIF(CT2:CT17,16)<2),0,1)

Is there a workaround so I can use the diagonal range?
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
There is a much simpler formula for your straight range:

=AND(COUNTIF(CT2:CT17,ROW(INDIRECT("1:16")))<2)

Confirm with CTRL-SHIFT-ENTER rather than just Enter.

Name your diagonalrange, I used diagonalrange is this example.

=AND(FREQUENCY(diagonalrange,ROW(INDIRECT("1:16")))<2)

Confirm with CTRL-SHIFT-ENTER rather than just Enter.
 
Upvote 0
Very cool! I never knew ROW and INDIRECT could be used that way. I tried it for the diagonal and at first it didn't work. However I changed the values in quotes from 1:16 to 2:17 and it worked!
Thanks a lot for your help!
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,853
Members
452,361
Latest member
d3ad3y3

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