Using CountIf in VBA/Macros

dougd

New Member
Joined
Dec 2, 2005
Messages
1
Hi all

I am a new user to Excel and am struggling with a spreadsheet that takes 8 variables, the interaction of which will yield a specific output depending on a given rule-set.
For example: depending on whether or not one figure in a group of three is less than, say, a 2 and that the remaining 5 numbers remain constant an x is yielded. The number of permutations here quickly mount up to something in the region of 4096. I have attempted to write a program to deal with this and decided I'd try it in a macro. I find myself in a quandry however: in the formula bar I can use CountIf to identify how many numbers fall below a set level in either of the two groups of numbers (3 in the first group and 5 in the second), which then satisfies the AND part of the If statements to yield a given outcome. However, because of the complexity of the number of variables, and because of the limit on nested Ifs, I decided to use a macro ... except I can't find the equivalent for CountIf in macro/VBA world.
After all of this then, my question is: how do I accomplish the functionality of the CountIf statement in the macro/VBA environment?

Thanks for any assistance rendered.
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,501
Messages
5,832,088
Members
430,110
Latest member
Chyke_mxl

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
Top