Excel VBA Count # of Cells within Max and Min in a Table

5 pts.
Tags:
COUNTIF statement
Excel VB code
Excel VBA
Visual Basic
How do you write a VBA macro that count the numbers cell within a selected table that falls between a maximum and minimum number?

Software/Hardware used:
Excel VBA
ASKED: November 11, 2010  3:24 AM
UPDATED: November 25, 2010  7:25 PM

Answer Wiki

Thanks. We'll let you know when a new response is added.

You could use some code like this:

<pre> With Application.WorksheetFunction
Range(“a1″) = .CountIf(Range(“a2:e5″), “>=0″) – .CountIf(Range(“a2:e5″), “>2″)
End With</pre>

This example code would count the cells with values between 0 and 2 in range A2:E5, and will put thre result in cell A1.

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following