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

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
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,221,443
Messages
6,159,907
Members
451,601
Latest member
terrynelson55

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