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

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.

Forum statistics

Threads
1,214,957
Messages
6,122,466
Members
449,086
Latest member
kwindels

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