How to check cells in a range for a value

B

BCS

I have written a macro that compares one set of values with another. 99% of
the time, the cells in the results table are 0. Instead of keeping the
workbook open just so I can make sure all the cells in the range are indeed
0, can I add this check to my macro so that a message box pops up only if
one of the cells has a value > 5 otherwise close the workbook. I know I can
check cell by cell using a loop, but I'd rather use some sort of Range
syntax to check it all in one fell swoop.

Thanks,

Barry
 
R

Ron de Bruin

You can check it like this

If Application.WorksheetFunction.CountIf(Range("a1:a10"), ">5") <> 0 Then
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top