0% found this document useful (0 votes)
9 views

How To Count Cells in A Range With A Value Less Than Another Cell in Excel - Stack Overflow

Uploaded by

pubgate
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

How To Count Cells in A Range With A Value Less Than Another Cell in Excel - Stack Overflow

Uploaded by

pubgate
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

27/11/2020 How to count cells in a range with a value less than another cell in excel?

- Stack Overflow

How to count cells in a range with a value less than another cell in excel?
Asked 6 years, 11 months ago Active 6 years, 11 months ago Viewed 12k times

My Table looks like below

if "team1" value is less than "general" value in that month, then it has blue color, if "team2" value is less than "general" value in that
month, then it has pink color,

Now I want to count how many blue colored and how many pink colored cells on each row in a year (cells AK3 and AL3)

What is the most appropriate formula for that?

excel count excel-formula conditional-formatting

edited Dec 10 '13 at 9:28 asked Dec 10 '13 at 8:29


Siddharth Rout alwbtc
133k 15 183 233 21.9k 49 115 170

Your image attachment is not readable. – Youbaraj Sharma Dec 10 '13 at 8:32

Were you able to open that link? – alwbtc Dec 10 '13 at 8:34

Yep but the image is too small, and not able to download it also – Youbaraj Sharma Dec 10 '13 at 8:39

After opening the link, you can click on the image, so that the image will be zoomed in. – alwbtc Dec 10 '13 at 8:46

3 Answers Active Oldest Votes

EDIT: merged two answers here:


By using our site, you acknowledge that you have read and understand our Cookie Policy, Privacy Policy, and our Terms of Service.

https://stackoverflow.com/questions/20489472/how-to-count-cells-in-a-range-with-a-value-less-than-another-cell-in-excel/20491479#20491479 1/6
27/11/2020 How to count cells in a range with a value less than another cell in excel? - Stack Overflow

1 This formula will do what you are looking for, assuming you move everything one column to the right (adding an empty column in
column A):

=SUM(IF(C2:AK2="Team1";IF(C3:AK3 < B3:AJ3;1;0)))

What this does is that it first looks if you have Team1 in the column. It then proceeds to check if the data below is less than the one
preceding that. It is important you have the last if as A and the others as B because otherwise it will summarise the wrong data. (For
team2 you will have to change the last B3:AJ3 to A3:AI3)

Also, use shift+enter when you enter this to make sure it becomes an array formula.

I would highly recommend you switch your columns and rows to a more standardised form first in order to have an easier workflow

with your data. I mean something like this

I would then recommend you check out the answer for a similar question here. To summarise, you gather the data in one column and
then use a

=SUM(IF(B:B < A:A;1;0))

assuming you have team1 in column B and general in column A.


By using our site, you acknowledge that you have read and understand our Cookie Policy, Privacy Policy, and our Terms of Service.

https://stackoverflow.com/questions/20489472/how-to-count-cells-in-a-range-with-a-value-less-than-another-cell-in-excel/20491479#20491479 2/6
27/11/2020 How to count cells in a range with a value less than another cell in excel? - Stack Overflow

edited May 23 '17 at 12:21 answered Dec 10 '13 at 8:49


Community ♦ MagneTism
1 1 567 1 6 23

I cannot switch the columns and rows, I have to preserve the table structure as it is. Isn't there a way? – alwbtc Dec 10 '13 at 9:00

I just figured one out :) I will add a new answer – MagneTism Dec 10 '13 at 9:07

Better form to combine your two answers into one post. – brettdj Dec 10 '13 at 9:20

2 Changed to having both of the answers in one post, hope this helps! – MagneTism Dec 10 '13 at 9:34

You can use XL4 macros (Excel formula) to count up cells with different backcolor or even font colour in excel :) See this LINK. For
Font color the type_num is 24 . And for backcolor we will use 63
9
1. Open the Name Manager
2. Give a name. Say BackColor

3. Type this formula in Refers To =GET.CELL(63,OFFSET(INDIRECT("RC",FALSE),-1,0)) and click OK

By using our site, you acknowledge that you have read and understand our Cookie Policy, Privacy Policy, and our Terms of Service.

https://stackoverflow.com/questions/20489472/how-to-count-cells-in-a-range-with-a-value-less-than-another-cell-in-excel/20491479#20491479 3/6
27/11/2020 How to count cells in a range with a value less than another cell in excel? - Stack Overflow

The explanation of =GET.CELL() is mentioned in the above link.

Now let's say your workbook looks like this

Next put this formula in row 2.


By using our site, you acknowledge that you have read and understand our Cookie Policy, Privacy Policy, and our Terms of Service.

https://stackoverflow.com/questions/20489472/how-to-count-cells-in-a-range-with-a-value-less-than-another-cell-in-excel/20491479#20491479 4/6
27/11/2020 How to count cells in a range with a value less than another cell in excel? - Stack Overflow

=backcolor

Next put =COUNTIF(A2:J2,8) and =COUNTIF(A2:J2,7) in cell C5 and C6 respectively and you will get the total count of colors.

edited May 23 '17 at 12:29 answered Dec 10 '13 at 10:08


Community ♦ Siddharth Rout
1 1 133k 15 183 233
By using our site, you acknowledge that you have read and understand our Cookie Policy, Privacy Policy, and our Terms of Service.

https://stackoverflow.com/questions/20489472/how-to-count-cells-in-a-range-with-a-value-less-than-another-cell-in-excel/20491479#20491479 5/6
27/11/2020 How to count cells in a range with a value less than another cell in excel? - Stack Overflow

Try this:

1 in B4 put this formula:

=IF(B2="Team1",IF(B3<A3,1,0),IF(B2="Team2",IF(B3<OFFSET(A3,0,-1),1,0),""))

Then then copy it till AJ4 .

Then in AK3 put this formula:

=COUNTIFS($A$2:$AJ$2,"Team1",$A$4:$AJ$4,1)

Similarly in AL3 put this formula.

=COUNTIFS($A$2:$AJ$2,"Team2",$A$4:$AJ$4,1)

Hope this approach works for you.

edited Dec 10 '13 at 9:41 answered Dec 10 '13 at 9:29


L42
18.3k 9 37 60

Excel cannot count colors Are you sure? :) – Siddharth Rout Dec 10 '13 at 9:30

@SiddharthRout i mean using built in formula. LOL. he doesn't want VBA. But if there is a built in function that can do, please enlighten me. :) – L42
Dec 10 '13 at 9:33

Yes I meant using formulas. You can use XL4 macros (Excel formula) to count up cells with different backcolor or even font colour in excel :) See
this LINK. For Font color it is 24 . However I don't remember the value for backcolor . It sure can be found using Google :) – Siddharth Rout Dec
10 '13 at 9:36

@SiddharthRout that's why i said enlighten us. :) LOL i already edited my answer hahaha. – L42 Dec 10 '13 at 9:41

By using our site, you acknowledge that you have read and understand our Cookie Policy, Privacy Policy, and our Terms of Service.

https://stackoverflow.com/questions/20489472/how-to-count-cells-in-a-range-with-a-value-less-than-another-cell-in-excel/20491479#20491479 6/6

You might also like