简体   繁体   English

我如何从具有指定值的单元格开始计算excel中的单元格?

[英]How do I Count cells in excel, starting with a cell that has a specified value?

在此处输入图片说明 The question is slightly confusing, so I will do my best to elaborate. 这个问题有些令人困惑,所以我会尽力加以阐述。 I have a series of cells in a row with all of the cells in the row with a value of 0 and one cell having a value of 1. I want to use the COUNT function to count all of the cells to the right of the cell that contains the value of 1, including that cell. 我在一行中有一系列单元格,该行中的所有单元格的值为0,而一个单元格的值为1。我想使用COUNT函数对单元格右边的所有单元格进行计数包含值1(包括该单元格)。 I would then use this number of counted cells in another equation. 然后,我将在另一个方程式中使用此数量的计数单元格。 Does anyone have any suggestions on how to do this? 有人对此有任何建议吗? I have tried using a lookup function inside of the count function, but it has not worked. 我试过在count函数中使用查找函数,但是没有用。 This is my closest guess: 这是我最接近的猜测:

=COUNT(Lookup(1,A1:J1):J1)

This results in an error. 这会导致错误。 Do I need to use VBA to make this work or should I be able to write an equation? 我需要使用VBA来完成这项工作还是应该写一个方程式? I appreciate the help, or if there are any other strategies that I can use to attain the result I am looking for. 我很感谢您的帮助,或者如果我可以使用其他任何方法来获得想要的结果。

Edit: I am adding in some sample data and expected results. 编辑:我正在添加一些示例数据和预期结果。 I am trying to count all of the cells to the right of the "1" including the cell containing the "1". 我正在尝试计算“ 1”右边的所有单元格,包括包含“ 1”的单元格。 So in this example, I would expect the formula to return "13" as there are 12 cells to the right of the "1" 因此,在此示例中,我希望公式返回“ 13”,因为“ 1”的右侧有12个单元格

这是数据的示例图片

You can use OFFSET() and MATCH(): 您可以使用OFFSET()和MATCH():

在此处输入图片说明

That last "50" is a bit of a guess since I'm not sure how far to the right you want to count... 最后一个“ 50”有点猜测,因为我不确定您要计算的右边有多远...

...and re-reading your question it's not clear if you only want to count values of 1 or if you also need to count other values as long as they're to the right of the first 1. ...并重新阅读您的问题,不清楚是只想计数1还是只需要计数其他值在第一个1的右边。

With data in A1 through J1 , consider: 对于A1J1中的数据,请考虑:

=10-MATCH(1,A1:J1,0)+1

在此处输入图片说明

In this case. 在这种情况下。 4 is the number of cells from G1 through J1 , inclusive. 4是从G1J1 (含)的单元数。

You can use this formula: 您可以使用以下公式:

=COUNTA(INDEX($A$1:$J$1,1,MATCH(1,$A$1:$J$1,0)):INDEX($A$1:$J$1,1,10))

The benefit to use this is it is not a volatile function, and it will also work for 1 appears in the last column. 使用它的好处是它不是易失性函数,并且也适用于最后一栏中出现的1

Assuming your range of 0 and 1 values is in row 2, starting from column B, use this formula in B3 and copy it across for as far as you need: 假设您的01值范围在第2行中,从B列开始,请在B3中使用此公式,并根据需要复制它:

=IFERROR(COUNT($B2:B2)+1-MATCH(1,$B2:B2,0),0)

在此处输入图片说明


You could also use a formula of 您还可以使用以下公式

=IF(A3>0,1+A3,IF(B2=1,1,0))

but that could cause issues if you have something in cell A3 itself. 但是如果您在A3单元格中有东西,可能会导致问题。

You can use "COUNTIF" formula to count number of occurrences of specific number in a range of cells. 您可以使用“ COUNTIF”公式来计算一系列单元格中特定数字的出现次数。

To count no of occurrences in a row. 连续计数没有发生的次数。

=COUNTIF(1:1,1) = COUNTIF(1:1,1)

If it is in a column then 如果在列中

=COUNTIF(A:A,1) = COUNTIF(A:A,1)

Hope you are looking for a countif function. 希望您正在寻找一个countif函数。

COUNTIF(A1:A10, 1)

The above function counts the cell that has value 1 within the range A1:A10 上面的函数计算范围A1:A10中值为1的单元格

暂无
暂无

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

相关问题 如何使用VBA或公式对Excel范围内具有特定值且具有注释的单元格进行计数? - How do I count cells with in a range in excel with specific value that has a comment using vba or formula? 如何使用VBA宏从指定的单元格开始计算Excel中的行 - How to count rows in excel starting in specified cell with vba macro EXCEL如果单元格具有值,如何忽略单元格 - EXCEL How do I ignore a cell if a cell has a value 如何计算值小于excel中另一个单元格的范围内的单元格? - How to count cells in a range with a value less than another cell in excel? 在Excel中,如何计算空白单元格的数量,直到下一个非空白单元格 - In Excel, How do I count the number of blank cells until the next non-blank cell 当描述单元格中有特定单词时,如何复制单元格值 - How do I copy cells value when the description cell has a specific word in cell 在Excel中,如果相邻列具有特定值,如何计算列中的空白单元格? - In Excel, how do you count a blank cell in a column if an adjacent column has a certain value? 如果不同的单元格是特定值,我怎么才能计算单元格? - How can I only count cells if a different cell is a specific value? 如何检查哪些单元格属于合并单元格并使用 c# Excel Interop 获取合并单元格的值? - How do I check which cells belong to a merged cell and get the merged cell's value using c# Excel Interop? EXCEL:如何计算多个单元格中的值模式? - EXCEL: How do I count a pattern of values across multiple cells?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM