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

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
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]
[TH]Cell[/TH]
[TH="align: left"]Formula[/TH]
[/TR]
[TR]
[TH]M2[/TH]
[TD="align: left"]=SUMPRODUCT(--(COUNTIF(responses,M$1)))[/TD]
[/TR]
[TR]
[TH]N2[/TH]
[TD="align: left"]=SUMPRODUCT(--(COUNTIF(responses,N$1)))[/TD]
[/TR]
[TR]
[TH]O2[/TH]
[TD="align: left"]=SUMPRODUCT(--(COUNTIF(responses,O$1)))[/TD]
[/TR]
[TR]
[TH]P2[/TH]
[TD="align: left"]=SUMPRODUCT(--(COUNTIF(responses,P$1)))[/TD]
[/TR]
[TR]
[TH]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]
[TH]Name[/TH]
[TH="align: left"]Refers To[/TH]
[/TR]
[TR]
[TH]responses[/TH]
[TD="align: left"]=OFFSET(Sheet1!$S$2,,,,COUNTIF(Sheet1!$S$2:$XFD$2,"?*"))[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]

Oh yes - this is working too.
Geez there are so many ways to solve the same problem in XLS.

Glad that the people here are very helpful too.
Thanks for the solution.
 
Upvote 0
Oh yes - this is working too.
Geez there are so many ways to solve the same problem in XLS.

Glad that the people here are very helpful too.
Thanks for the solution.

But not efficient because of array-processing and the volatile OFFSET function. Potentially wrong too when there are empty/blanks cells.
 
Upvote 0
Is there a scenario where we couldn't just use;

=COUNTIF($S$2:$XFD$2,M$1)?
 
Upvote 0

Forum statistics

Threads
1,224,828
Messages
6,181,209
Members
453,023
Latest member
alabaz

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