简体   繁体   English

如何计算值小于excel中另一个单元格的范围内的单元格?

[英]How to count cells in a range with a value less than another cell in excel?

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, 如果“team1”值小于该月份的“一般”值,则它具有蓝色,如果“team2”值小于该月的“一般”值,则它具有粉红色,

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) 现在我想计算一年中每行上有多少蓝色和多少个粉红色的细胞(细胞AK3和AL3)

What is the most appropriate formula for that? 最合适的配方是什么?

You can use XL4 macros (Excel formula) to count up cells with different backcolor or even font colour in excel :) See this LINK . 您可以使用XL4宏(Excel公式)来计算excel中具有不同背景颜色甚至字体颜色的单元格:)请参阅此链接 For Font color the type_num is 24 . 对于Font颜色, type_num24 And for backcolor we will use 63 对于背景颜色,我们将使用63

  1. Open the Name Manager 打开名称管理器
  2. Give a name. 给个名字。 Say BackColor BackColor
  3. Type this formula in Refers To =GET.CELL(63,OFFSET(INDIRECT("RC",FALSE),-1,0)) and click OK 在引用=GET.CELL(63,OFFSET(INDIRECT("RC",FALSE),-1,0))键入此公式,然后单击“确定”。

在此输入图像描述

The explanation of =GET.CELL() is mentioned in the above link. 上面的链接中提到了=GET.CELL()的解释。

Now let's say your workbook looks like this 现在让我们说你的工作簿看起来像这样

在此输入图像描述

Next put this formula in row 2. 接下来将此公式放在第2行。

=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. 接下来分别在单元格C5C6 =COUNTIF(A2:J2,8)=COUNTIF(A2:J2,7) ,您将获得颜色的总数。

在此输入图像描述

EDIT: merged two answers here: 编辑:在这里合并两个答案:

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): 假设您将所有内容向右移动一列(在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. 这样做的第一步看起来你是否在列中有Team1。 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. 重要的是你将最后一个if作为A而其他人作为B,因为否则它会汇总错误的数据。 (For team2 you will have to change the last B3:AJ3 to A3:AI3) (对于team2,您必须将最后一个B3:AJ3更改为A3:AI3)

Also, use shift+enter when you enter this to make sure it becomes an array formula. 此外,输入此选项时使用shift + enter以确保它成为数组公式。


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. 假设您在B列中有team1,在A列中有一般。

Try this: 尝试这个:

in B4 put this formula: B4放了这个公式:

=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 . 然后将其复制到AJ4

Then in AK3 put this formula: 然后在AK3放入这个公式:

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

Similarly in AL3 put this formula. 同样在AL3放了这个公式。

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

Hope this approach works for you. 希望这种方法适合你。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Excel计数A列中的单元格小于B列中的相应单元格的范围内的次数 - Excel Count number of times in range that cells in column A are less than corresponding cell in column B Excel-如果小于另一个单元格中的日期,则设置单元格的格式 - Excel - Format cells in a row if less than date in another cell Excel中带有countif的单元格区域中的值大于其他范围中的值 - Value in a cell range greater than a value in another range with countif in excel 如果单元格值大于0,excel vba将单元格复制到另一个工作表 - excel vba copy cells to another sheet if cell value is greater than 0 Excel:如果范围等于上方的单元格,则对范围内的单元格进行计数 - Excel: Count cells in range if they are equal to cell above 如何从 excel 表中的单元格值获取单元格范围? - How to get a cells range from cell value in excel sheet? 在Excel VBA中使用for if来计算直到最后一行的单元格值,但同时要使其小于30 - Using for if in Excel VBA to count cells value until last row but at the same time want to make it less than 30 如何在Excel中大于1的单元格范围内找到最小值? - How to find minimum value on range of cells that are greater than 1 in excel? (Excel) 有没有办法根据另一个单元格的值从一系列单元格中对单元格进行条件格式设置? - (Excel) Is there a way to conditional format a cell from a range of cells based on the value of an another cell? VBA Excel对具有特定值的范围内的单元格进行计数 - VBA Excel count cells in a range with a specific value
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM