Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
BCS BCS is offline
external usenet poster
 
Posts: 4
Default How to check cells in a range for a value

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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default How to check cells in a range for a value

You can check it like this

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


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)
www.rondebruin.nl



"BCS" wrote in message ...
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




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to check if the values in a range of cells are greater than 0 DP Excel Worksheet Functions 3 March 19th 10 01:31 PM
Check text in range of cells tommcbrny Excel Discussion (Misc queries) 2 September 11th 09 05:11 PM
How do I write formula to check a range of cells? Tayo Excel Worksheet Functions 5 August 27th 09 05:53 PM
check for FALSE values in a range of cells in VBA Dave F[_2_] Excel Discussion (Misc queries) 2 August 7th 07 04:12 PM
How do I get Excel to display a range of cells with a check box? bobm Excel Discussion (Misc queries) 2 October 21st 05 07:37 PM


All times are GMT +1. The time now is 08:37 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"