简体   繁体   English

如何计算不为空的单元格

[英]How to count cells that are not empty

I have a list of down regulated gene probes for two different clones. 我有两个不同克隆的下调基因探针清单。

I have used the formula =IF(ISERROR(MATCH(F2,$H$2:$H$1670,0)),"",F2) to give me a list of genes that are down regulated in both clones. 我已经使用公式=IF(ISERROR(MATCH(F2,$H$2:$H$1670,0)),"",F2)给我列出了两个克隆中均下调的基因。

However, I now need to count how many there are and when I try to copy and paste the list to try to remove blank cells I am unable to and they disappear as they are formulas. 但是,我现在需要计算有多少个,当我尝试复制并粘贴列表以尝试删除我无法删除的空白单元格时,它们将作为公式消失。

I have tried using COUNTA to count them but this gives me all of the genes in the left column as technically all middle columns are filled by the formula. 我尝试使用COUNTA来对它们进行计数,但是这给了我左列中的所有基因,因为从技术上讲,所有中间列都由公式填充。

G.Ac down               Shared down regulated   Mc.Ac down 
GENE:JGI_V11_619450303  GENE:JGI_V11_619450303  GENE:JGI_V11_3219080103
GENE:JGI_V11_2644330202                         GENE:JGI_V11_534070103
GENE:JGI_V11_1064490203 GENE:JGI_V11_1064490203 GENE:JGI_V11_3146980103
GENE:JGI_V11_3327160202                         GENE:JGI_V11_3018650102
GENE:JGI_V11_3179550203                         GENE:JGI_V11_3018650202
GENE:JGI_V11_3050490103                         GENE:JGI_V11_3146980203
GENE:JGI_V11_1064490103 GENE:JGI_V11_1064490103 GENE:JGI_V11_2378650103
GENE:JGI_V11_1044440103                         GENE:JGI_V11_2378650303
GENE:JGI_V11_3277080303 GENE:JGI_V11_3277080303 GENE:JGI_V11_3146980303

How do I either get a copy of all the genes that appear in the middle row OR how do I count the number of genes that appear in the middle row? 如何获得出现在中间行的所有基因的副本,或者如何计算出现在中间行的基因的数量?

You can approach this one of two ways: 您可以采用以下两种方法之一进行处理:

  • Use one formula to count how many genes appear in the middle column, or 使用一个公式计算中间列中出现了多少个基因, 或者
  • Get a unique list of all genes that appear in the middle column. 获取出现在中间列的所有基因的唯一列表。

I'll show you both solutions, below. 我将在下面显示两种解决方案。


Use one formula to count the number of populated cells in a column that also has formulas returning "": 使用一个公式来计算具有返回“”的公式的列中已填充单元格的数量:

You'll want to use the following formula: 您将要使用以下公式:

=COUNTIF($B$2:$B$10,">*")

with $B$2:$B$10 being your range covering your Shared down regulated column (sans the header). 其中$B$2:$B$10是覆盖“ 向下调整”列的范围(没有标题)。 Change range locations as needed. 根据需要更改范围位置。

使用COUNTIF

This formula works by counting all cells in the specified range that have at least one character (done by using the wildcard * within the criteria part of the function). 此公式通过对指定范围内具有至少一个字符的所有单元格进行计数(通过在函数的criteria部分内使用通配符*完成)来进行计算。

NOTE: This formula only works on cells that are either formatted as text, or are not numbers. 注意:此公式仅适用于格式为文本或不是数字的单​​元格。 Your data set is perfectly acceptable as your data seems to be all strings. 您的数据集完全可以接受,因为您的数据似乎全是字符串。


Return a unique, contiguous list of values from a single column while ignoring blank or ="" cells: 从单个列返回唯一,连续的值列表,而忽略空白或=“”单元格:

If you'd rather return a unique list of values from your second column, use the following array formula in F2 (this must be committed using Ctrl + Shift + Enter or it won't work): 如果您希望从第二列返回唯一的值列表,请在F2使用以下数组公式( 必须使用Ctrl + Shift + Enter提交,否则将不起作用):

=IFERROR(INDEX($B$2:$B$10,MATCH(0,COUNTIF($F$1:$G1,$B$2:$B$10),0)),"")

with $B$2:$B$10 being your range covering your Shared down regulated column (sans the header) and $F$1:$G1 being the new column header you created (mine is called Genes List ) to hold this unique list ( see image below ). $B$2:$B$10是您的范围,涵盖了Shared down向下调节的列(没有标题),而$F$1:$G1是您创建的新列标题(我的名称为Genes List )来保存此唯一列表( 请参见下图 )。 Change range locations as needed. 根据需要更改范围位置。

Once you commit the formula in the first cell of the newly created column, you can copy the formula down. 在新创建的列的第一个单元格中提交公式后,可以向下复制公式。

创建一个唯一列表

With respect to $F$1:$G1 , you can either: 关于$F$1:$G1 ,您可以:
- put your new column header into F1 only (but still use $F$1:$G1 in your formula), or -把你的新的列标题为F1 (但仍使用$F$1:$G1在公式中),
- merge cells F1 and G1 together. -将单元格F1G1合并在一起。

The key to making sure your new, unique list excludes both blank cells as well as cells holding "" (via a formula return) is to ensure the range argument of the COUNTIF function covers both the header ( F1 ) as well as one blank cell ( G1 ) of your new column. 确保新的唯一列表排除空白单元格和包含""单元格(通过公式返回)的关键是确保COUNTIF函数的range参数既覆盖标头( F1 )又覆盖一个空白单元格( G1 )的新列。 The blank cell ( G1 ) ensures that all blank/empty cells in your data column (column B ) are accounted for, preventing them from leaving gaps in your new list. 空白单元格( G1 )确保考虑到数据列(列B )中的所有空白/空单元格,从而防止它们在新列表中留下空白。 Wrapping it all up in IFERROR allows you to drag the new range as far down as you want without having to see errors all over the place. 将其全部包裹在IFERROR可让您将新范围拖至所需的最低位置,而不必到处查看错误。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM