简体   繁体   English

Excel-COUNTIF

[英]excel - COUNTIF

I have a table with three columns. 我有一张三列的桌子。 Column C contains the formulas. C列包含公式。 Right now, I'm putting in the formulas by hand. 现在,我手动输入公式。 I need a modified version of the same formula that I can drag-down and uses the correct ranges. 我需要相同公式的修改版本,可以向下拖动并使用正确的范围。

|      Column A           |     Column B        |        Column C
|-------------------------|---------------------|-----------------------------
| abiding_jj citizen_nn   |    (abiding1)       |    1[=COUNTIF(B$1:B$1,B1)]
| (BLANK ROW)             |                     | 
| abrupt_jj end_nn        |    (abrupt2)        |    2[=COUNTIF(B$3:B$7,B3)]
| abrupt_jj end_nn        |    (abrupt1)        |    3[=COUNTIF(B$3:B$7,B4)]
| abrupt_jj end_nn        |    (abrupt1)        |    3[=COUNTIF(B$3:B$7,B5)]
| abrupt_jj end_nn        |    (abrupt1)        |    3[=COUNTIF(B$3:B$7,B6)]
| abrupt_jj end_nn        |    (abrupt2)        |    2[=COUNTIF(B$3:B$7,B7)]
| (BLANK ROW)             |                     |
| abrupt_jj halt_nn       |    (abrupt1)        |    3[=COUNTIF(B$9:B$12,B9)]
| abrupt_jj halt_nn       |    (abrupt3)        |    1[=COUNTIF(B$9:B$12,B10)]
| abrupt_jj halt_nn       |    (abrupt1)        |    3[=COUNTIF(B$9:B$12,B11)]
| abrupt_jj halt_nn       |    (abrupt1)        |    3[=COUNTIF(B$9:B$12,B12)]

If I understand correctly, you want to treat observations that are separated by a blank row as different "groups". 如果我理解正确,您希望将由空白行分隔的观察结果视为不同的“组”。 This could be solved by adding an extra column that creates "group" numbers that you can then use in a countifs formula. 可以通过添加一个额外的列来创建“组”数字来解决此问题,然后可以在countifs公式中使用该数字。

An example with the "groups" in column A: A列中的“组”示例: 在此处输入图片说明

Column A contains 1 in A1, to mark the first group, and a formula in subsequent rows: =IF(ISBLANK(B#),A#+1,A#) (as shown in the snapshot, with # being the previous row). 列A在A1中包含1,以标记第一个组,并在随后的行中包含一个公式:= IF(ISBLANK(B#),A#+ 1,A#)(如快照中所示,其中#为前一行)。

It's not very elegant but it seems to do what you want. 它不是很优雅,但似乎可以满足您的要求。

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

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