使用COUNTIF函数,但省略隐藏的行?

时间:2016-12-28 20:57:27

标签: excel countif

我的公式是:

=SUM(COUNTIFS(P2:P5000,{"Update"}))

=COUNTIF(P2:P5000,"Update")

正好有23个单元格中包含“更新”字样。但是,我得到了46的结果。在我得到错误计数的地方可能导致这个问题?

LANDMAN PAR_NUM LESSEE  L_DATE  E_DATE  F_NAME  L_NAME  ACRES   ADDRESS CITY    STATE   ZIP PHONE   EMAIL   NOTES   STATUS
RH_12.2.2016    7-23-16 SOUTHWESTERN ENERGY 5/3/2011    5/2/2016    PAM DENNIS  99.80000000000  ROUTE 3 BOX 3233    KEYSER  WV  26726.00000000000   304-788-6612        RH 12/2/16 MULTIPLE INTEREST WILLING TO LOOK AT LEASE   Update
RH_12.2.2016    7-23-16 SOUTHWESTERN ENERGY 2/28/2011   2/27/2016       ESTATE OF MARGARET M. ENGLE 99.55000000000  58 SOUTH MEWS WOOD COURT    WOODLANDS   WV  77381.00000000000   717-560-2173        RH 12/2/16 EXEC. OF EST ANTHONY KURTZ NO ANSW MULTIPLE INTEREST Update
RH_12.2.2016    7-12-14 SOUTHWESTERN ENERGY 12/1/2008   11/30/2013  THELMA, DEC'D   DAUNETTA FROMHART HEIR OF THELMA    99.40000000000  1309 CENTER ST. MOUNDSVILLE WV  26041.00000000000   304-845-5531        RH 12/2/16 LM FOR DAUNETTA FROMHART Update
RH_12.2.2016    43287   CNX GAS / NOBLE ENERGY  12/16/2009  12/15/2014  THOMAS & JACELYN    JONES   99.22000000000  25 LEARY DR.    SAVVANAH    WV  31406.00000000000   912-351-9843        RH 12/2/16 LM FOR DAUNETTA FROMHART Update
RH_12.2.2016    7-5-18  CNX GAS / NOBLE ENERGY  8/18/2009   8/17/2014   PAUL    HIERONIMUS  98.15000000000  7 PLEASANT DR.  CAMERON WV  26033.00000000000   304-686-2746        RH 12/2/16 LM   Update
RH_12.2.2016    7-5-18  SOUTHWESTERN ENERGY 12/16/2010  12/15/2017      HAYHURST COMPANY    98.15000000000  PO BOX 5065 FAIRMONT    WV  26555   304-363-2068        RH 11/30 SPOKE TO ROBIN HE SAID CALL CHRISTINE DAVIS 304-363-7788 MUST BE THEIR LEASE FORM  Update
RH_12.2.2016    15-11-14    NISOURCE ENERGY 7/24/2009   7/23/2014   JOSEPH SCARLATA WILLIAM T.  97.34000000000  302 KUSER RD.   TRENTON NJ  8619.00000000000    609-587-2497        # DISCONNECTED  Update
RH_12.2.2016    12-3-5  GREAT LAKES ENERGY  12/21/2005  12/21/2010  BYRON R.    MOSS ET AL  97.06700000000  RD 3 BOX 112 A  WHEELING    WV  26003.00000000000   304-547-5755        RH 12/3 IN A LEASE TILL 2019    Update
RH_12.2.2016    14-11-10    CHESAPEAKE ENERGY   1/11/2010   1/10/2015   JAMES & JODI    FRANKLIN    97.03600000000  RD BOX 164 B    MOUNDSVILLE WV  26041.00000000000   304-845-2238        RH 12/3 IN A LEASE TILL 2019    Update
RH_12.2.2016    7-7-9.1 REPUBLIC ENERGY VENTURES    2/20/2012   2/20/2017   DONNIS S    TEDROW  96.84600000000  107 SAWMILL RD. WAYNESBURG  PA  15370.00000000000           RH 12/3/16 LM   Update
RH_12.2.2016    7-6-22  NISOURCE ENERGY 5/6/1903        MERRIS  HOWARD ET UX    95.97000000000  LOOKS TO BE HELD BY STORAGE LEASE   LOOKS TO BE HELD BY STORAGE LEASE   LOOKS TO BE HELD BY STORAGE LEASE   LOOKS TO BE HELD BY STORAGE LEASE   LOOKS TO BE HELD BY STORAGE LEASE       LOOKS TO BE HELD BY STORAGE LEASE   Update
RH_12.2.2016    7-8-14  CHESAPEAKE ENERGY   4/8/2009    4/7/2014    JOHN M  PADDEN  95.44000000000  1423 BATTLE RUN ROAD    TRIADELPHIA WV  26059.00000000000   304-547-0047        LM WITH WIFE    Update
RH_12.2.2016    7-11-4  NISOURCE ENERGY 12/16/1908      GEORGE  CHAMBERS ET UX  94.87000000000  LOOKS TO BE HELD BY STORAGE LEASE   LOOKS TO BE HELD BY STORAGE LEASE   LOOKS TO BE HELD BY STORAGE LEASE   LOOKS TO BE HELD BY STORAGE LEASE   LOOKS TO BE HELD BY STORAGE LEASE   LOOKS TO BE HELD BY STORAGE LEASE   LOOKS TO BE HELD BY STORAGE LEASE   Update
RH_12.2.2016    7-4-38  LEATHERWOOD         BROWN   RUTH E. 94.43040000000  DOES NOT OWN O&G    DOES NOT OWN O&G        DOES NOT OWN O&G    DOES NOT OWN O&G    DOES NOT OWN O&G    DOES NOT OWN O&G    Update
RH_12.2.2016    7-12-8  SOUTHWESTERN ENERGY 2/21/2009   2/20/2014   SARAH & ONWARD EMMETT   BURGE   94.16300000000  RR3 BOX 33 AVE  CAMERON WV  26033.00000000000   304-686-2265        PHONE HANGS UP AS SOON AS IT RINGS  Update
RH_12.2.2016    7-11-9  SOUTHWESTERN ENERGY 10/6/2006   10/6/2016   THEODORE W & MARY ANN   FINCK   94.12700000000  32 LOCUST AVE.  WHEELING    WV  26003.00000000000   LOOKS TO BE HELD BY STORAGE LEASE   LOOKS TO BE HELD BY STORAGE LEASE   LOOKS TO BE HELD BY STORAGE LEASE   Update
RH_12.2.2016    7-2-28  SOUTHWESTERN ENERGY 2/25/2012   2/24/2017   BRIAN S & KATHERINE KEY 93.80000000000  18564 RINGGOLD SOUTHERN ROAD    CIRCLEVILLE WV  43113.00000000000   NO NUMBER ON LEX-NEX            Update
RH_12.2.2016    7-22-1  CONSOLIDATION COAL                  93.37250000000  COULD NOT PULL LEASE                            Update
RH_12.2.2016    7-12-8  SOUTHWESTERN ENERGY 3/28/1916       MARY J, KIRKENDALE  COLE    93.36990000000  8601 DRAGON HWY CAMERON WV  26033.00000000000   304-686-4769        12/5/16 LM TRY BACK Update
RH_12.2.2016    9-19-21 PERKINS OIL & GAS           W VA DIV OF NATURAL RESOURCES       93.17830000000   RM 643 CAPITAL CMPL BLDG 3 CHARELSTON  WV  25305.00000000000   NO NUMBER ON LEX-NEX            Update
RH_12.2.2016    7-3-1   NISOURCE ENERGY 4/4/1908        JOSEPH R    JONES ET UX 92.00000000000  ROUTE 3 BOX 3233    KEYSER  WV  26726.00000000000   304-788-6612        PAM DENNIS IS HEIR  Update
RH_12.2.2016    7-11-12 NISOURCE ENERGY 10/8/1908       JOHN P  REID ET UX  92.00000000000  MARSHALL CO NOT WORKING TRY AGAIN                           Update
RH_12.2.2016    7-20-26 SOUTHWESTERN ENERGY 10/20/2009  10/19/2014  JANICE  MYSLIWIEC   91.60000000000  MARSHALL CO NOT WORKING TRY AGAIN                           Update

enter image description here

2 个答案:

答案 0 :(得分:0)

简单的答案是“更新”实际上填充在隐藏的行中。我不确定为什么COUNTIF包含这些行但是一旦删除了隐藏的行,我就没有问题。

答案 1 :(得分:0)

所以@ westman2222找到了解决方案:隐藏行中确实有Update个值,而COUNTIF正在计算它们。

解释是公式包括范围P2:P5000。无论该范围中的哪些单元格被隐藏或可见,该公式都会使用该范围。

这与用户界面显示的不同,至少在Excel 2013中显示:

screenshot

A1A3我输入了值1,4,3。然后我隐藏了行2=AVERAGE(A1:A3)使用全部范围,隐藏或不隐藏,因此返回8/3=2.667。但是,状态栏上的内置平均值仅使用值为13的可见行,因此返回4/2=2的平均值。

在VBA或工作表函数中,除非是否隐藏了特定函数的文档,否则使用范围内的所有单元格,除非您特别检查隐藏并专门处理它。