Using COUNTIFS in VBA from from a data worksheet to a macro page

harlesbarkly

New Member
Joined
Aug 18, 2014
Messages
4
Hello,
I was wondering if any “excel Studs” knew how to use the countIFs function in excel using strings found in a worksheet cells. This is the last stage of a code I have been working on for a few weeks now. Here is a example so you can better understand the goal of the task.

End Chart should look like this( last column needs to be filled)
[TABLE="width: 355"]
<tbody>[TR]
[TD]Year[/TD]
[TD]animal[/TD]
[TD]Location[/TD]
[TD]# at given location[/TD]
[/TR]
[TR]
[TD]Year 1[/TD]
[TD]Dog[/TD]
[TD]Shelter[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Year 1[/TD]
[TD]Cat[/TD]
[TD]Shelter[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Year 1[/TD]
[TD]Bird[/TD]
[TD]Shelter[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Year 1[/TD]
[TD]Dog[/TD]
[TD]Farm[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Year 1[/TD]
[TD]Cat[/TD]
[TD]Farm[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Year 1[/TD]
[TD]Bird[/TD]
[TD]Farm[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Year 1[/TD]
[TD]Dog[/TD]
[TD]"blank"[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Year 1[/TD]
[TD]Cat[/TD]
[TD]"blank"[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Year 1[/TD]
[TD]Bird[/TD]
[TD]"blank"[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Year 2[/TD]
[TD]Dog[/TD]
[TD]Shelter[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Year 2[/TD]
[TD]Cat[/TD]
[TD]Shelter[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Year 2[/TD]
[TD]Bird[/TD]
[TD]Shelter[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Year 2[/TD]
[TD]Dog[/TD]
[TD]Farm[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Year 2[/TD]
[TD]Cat[/TD]
[TD]Farm[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Year 2[/TD]
[TD]Bird[/TD]
[TD]Farm[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Year 2[/TD]
[TD]Dog[/TD]
[TD]"blank"[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Year 2[/TD]
[TD]Cat[/TD]
[TD]"blank"[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Year 2[/TD]
[TD]Bird[/TD]
[TD]"blank"[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Year 3[/TD]
[TD]Dog[/TD]
[TD]Shelter[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Year 3[/TD]
[TD]Cat[/TD]
[TD]Shelter[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Year 3[/TD]
[TD]Bird[/TD]
[TD]Shelter[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Year 3[/TD]
[TD]Dog[/TD]
[TD]Farm[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Year 3[/TD]
[TD]Cat[/TD]
[TD]Farm[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Year 3[/TD]
[TD]Bird[/TD]
[TD]Farm[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Year 3[/TD]
[TD]Dog[/TD]
[TD]"blank"[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Year 3[/TD]
[TD]Cat[/TD]
[TD]"blank"[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Year 3[/TD]
[TD]Bird[/TD]
[TD]"blank"[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

And the data that is used to count the # of occurrences looks like this
[TABLE="width: 362"]
<tbody>[TR]
[TD][/TD]
[TD][/TD]
[TD="colspan: 3"]Location in year[/TD]
[/TR]
[TR]
[TD]Name[/TD]
[TD]Animal[/TD]
[TD]Year 1[/TD]
[TD]Year 2[/TD]
[TD]Year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
[TD]Shelter[/TD]
[TD][/TD]
[TD]Farm[/TD]
[/TR]
[TR]
[TD]Bucky[/TD]
[TD]Dog[/TD]
[TD]Farm[/TD]
[TD]Farm[/TD]
[TD]Farm[/TD]
[/TR]
[TR]
[TD]Inru[/TD]
[TD]Bird[/TD]
[TD]Shelter[/TD]
[TD]Shelter[/TD]
[TD]Shelter[/TD]
[/TR]
[TR]
[TD]enru[/TD]
[TD]Bird[/TD]
[TD][/TD]
[TD]Farm[/TD]
[TD]Farm[/TD]
[/TR]
[TR]
[TD]luffy[/TD]
[TD]Dog[/TD]
[TD][/TD]
[TD]Shelter[/TD]
[TD]Shelter[/TD]
[/TR]
[TR]
[TD]midori[/TD]
[TD]Bird[/TD]
[TD][/TD]
[TD][/TD]
[TD]Farm[/TD]
[/TR]
[TR]
[TD]oracle[/TD]
[TD]Bird[/TD]
[TD][/TD]
[TD][/TD]
[TD]Farm[/TD]
[/TR]
[TR]
[TD]banksy[/TD]
[TD]Cat[/TD]
[TD]Shelter[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]



Note: "Blank" means that the data cell is empty.
I hope all of your days are going well.
From,
a young padawan disciple
 

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