COUNTIF for Increasing Column

sk2018

New Member
Joined
Jul 7, 2018
Messages
26
Office Version
  1. 2016
Platform
  1. Windows
[TABLE="class: outer_border, width: 600"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[TD]E[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]Apple[/TD]
[TD]Orange[/TD]
[TD]Kiwi[/TD]
[TD]Response 1[/TD]
[TD]Response 2[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]=countif(D2:E2, "Apple")
[/TD]
[TD]=countif(D2:E2,"Orange")[/TD]
[TD]=countif(D2:E2,"Kiwi")[/TD]
[TD]Apple[/TD]
[TD]Kiwi[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

Do refer to the above for your understanding.

Given that as time goes by, I will have data add on Column F, G, H, I and etc onwards.
Is there any way for me to count the number of Apple, Orange, Kiwi starting from Column D onwards.


I do not want to set it as Table as I have plenty of worksheets and need to distribute to others to use.
I'm not considering of using the range of D2:Z2 or whichever wide range as to avoid any deletion of columns that may take place.

Is there any formula that will be able to detect the last notblank columns and make it as the range?


Thanks.
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
=COUNTIFS($D2:INDEX($2:2,MATCH(REPT("z",255),$2:2)),"apple")

will count all apple occurrences from D2 on.


Further question on this.
The example that I gave is on 3 items: Apple, Orange, Kiwi.

Now I'm increasing the items to 5: Apple, Orange, Kiwi, Grapes, Cherries.
However I faced circular reference problem for Grapes (4th Item) and Cherries (5th Item).

Does that formula you proposed has a limitation to be used only on 3 items?

Thanks
 
Upvote 0
No limitation.

Would you post the data you have? (Do not post any formula though, just the expected results.)


[TABLE="width: 550"]
<tbody>[TR]
[TD][/TD]
[TD]L[/TD]
[TD]M[/TD]
[TD]N[/TD]
[TD]O[/TD]
[TD]P[/TD]
[TD]Q[/TD]
[TD]R[/TD]
[TD]S[/TD]
[TD]T[/TD]
[TD]U[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]Total[/TD]
[TD]Apple[/TD]
[TD]Orange[/TD]
[TD]Kiwi[/TD]
[TD]Grapes[/TD]
[TD]Cherries[/TD]
[TD]Sample Picklist[/TD]
[TD]Response 1[/TD]
[TD]Response 2[/TD]
[TD]Response 3[/TD]
[/TR]
[TR]
[TD]2 Formula[/TD]
[TD]u can ignore this[/TD]
[TD]=COUNTIFS($S2:INDEX($2:2, MATCH(REPT("z",255),$2:2)),"Apple")[/TD]
[TD]=COUNTIFS($S2:INDEX($2:2, MATCH(REPT("z",255),$2:2)),"Orange")[/TD]
[TD]=COUNTIFS($S2:INDEX($2:2, MATCH(REPT("z",255),$2:2)),"Kiwi")[/TD]
[TD]=COUNTIFS($S2:INDEX($2:2, MATCH(REPT("z",255),$2:2)),"Grapes")[/TD]
[TD]=COUNTIFS($S2:INDEX($2:2, MATCH(REPT("z",255),$2:2)),"Cherries")[/TD]
[TD]<this is="" the="" picklist="" values="" of="" all="" 5="" items,="" not="" to="" be="" counted="">
</this>[/TD]
[TD]Apple[/TD]
[TD]Cherries[/TD]
[TD]Kiwi[/TD]
[/TR]
[TR]
[TD]2 Value[/TD]
[TD]u can ignore this[/TD]
[TD]1[/TD]
[TD][/TD]
[TD]1[/TD]
[TD][/TD]
[TD]1[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

Any problem with my formula?
Coz I;m having problem with circular reference specifically at P2

Column R - I have set a list of picklist value using Data Validation that consists of Apple, Orange, Kiwi, Grapes, Cherries. This serves mainly as a reference. And it should not be counted as part of the Column M to Column Q
 
Last edited:
Upvote 0
You could use this method;


MNOPQRSTU
AppleOrangeKiwiGrapesCherriesSample PicklistResponse 1Response 2Response 3
AppleCherriesKiwi

<tbody>
[TD="align: center"]1[/TD]

[TD="align: center"]2[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"][/TD]

</tbody>
Sheet1

[TABLE="width: 85%"]
<tbody>[TR]
[TD]Worksheet Formulas[TABLE="width: 100%"]
<tbody>[TR="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]
[TH]Cell[/TH]
[TH="align: left"]Formula[/TH]
[/TR]
[TR]
[TH="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]M2[/TH]
[TD="align: left"]=SUMPRODUCT(--(COUNTIF(responses,M$1)))[/TD]
[/TR]
[TR]
[TH="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]N2[/TH]
[TD="align: left"]=SUMPRODUCT(--(COUNTIF(responses,N$1)))[/TD]
[/TR]
[TR]
[TH="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]O2[/TH]
[TD="align: left"]=SUMPRODUCT(--(COUNTIF(responses,O$1)))[/TD]
[/TR]
[TR]
[TH="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]P2[/TH]
[TD="align: left"]=SUMPRODUCT(--(COUNTIF(responses,P$1)))[/TD]
[/TR]
[TR]
[TH="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]Q2[/TH]
[TD="align: left"]=SUMPRODUCT(--(COUNTIF(responses,Q$1)))[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]

[TABLE="width: 85%"]
<tbody>[TR]
[TD]Workbook Defined Names[TABLE="width: 100%"]
<tbody>[TR="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]
[TH]Name[/TH]
[TH="align: left"]Refers To[/TH]
[/TR]
[TR]
[TH="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]responses[/TH]
[TD="align: left"]=OFFSET(Sheet1!$S$2,,,,COUNTIF(Sheet1!$S$2:$XFD$2,"?*"))[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,875
Members
452,363
Latest member
merico17

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top