Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 187
Default check for FALSE values in a range of cells in VBA

I have a macro which prompts the user to input a variety of values,
which values are put into a range of cells for the purposes of
calculation.

Say the range is A1:A7.

If the user hits the cancel button on the pop-up window, FALSE is
returned; this FALSE generates errors in the formulas that depend upon
these cells. Is there VBA code I can use that essentially says "if
any cell in the range A1:A7 contains the value FALSE, replace the
contents of all those cells with "" ? (i.e., an empty string.)

Dave

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,202
Default check for FALSE values in a range of cells in VBA

I have a macro which prompts the user to input a variety of values,
which values are put into a range of cells for the purposes of
calculation.

Say the range is A1:A7.

If the user hits the cancel button on the pop-up window, FALSE is
returned; this FALSE generates errors in the formulas that depend upon
these cells. Is there VBA code I can use that essentially says "if
any cell in the range A1:A7 contains the value FALSE, replace the
contents of all those cells with "" ? (i.e., an empty string.)


Are you looking for code something like this?

Dim R As Range
Application.EnableEvents = False
For Each R In Range("A1:A7")
If R.Value = False Then R.Value = ""
Next
Application.EnableEvents = True

Rick
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 187
Default check for FALSE values in a range of cells in VBA

Yes, perfect, thanks.


n Aug 7, 10:57 am, "Rick Rothstein \(MVP - VB\)"
wrote:
I have a macro which prompts the user to input a variety of values,
which values are put into a range of cells for the purposes of
calculation.


Say the range is A1:A7.


If the user hits the cancel button on the pop-up window, FALSE is
returned; this FALSE generates errors in the formulas that depend upon
these cells. Is there VBA code I can use that essentially says "if
any cell in the range A1:A7 contains the value FALSE, replace the
contents of all those cells with "" ? (i.e., an empty string.)


Are you looking for code something like this?

Dim R As Range
Application.EnableEvents = False
For Each R In Range("A1:A7")
If R.Value = False Then R.Value = ""
Next
Application.EnableEvents = True

Rick



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
Check if Conditional Format is True or False / Check cell Color Kevin McCartney Excel Worksheet Functions 5 June 29th 07 11:12 AM
Simple Check Box - without True/False values Lisa Excel Discussion (Misc queries) 5 February 13th 07 04:20 PM
Return True/False to check duplicate items in a range with one for Tetsuya Oguma Excel Worksheet Functions 10 October 21st 06 03:20 AM
Q: check a range values JIM.H. Excel Discussion (Misc queries) 2 October 21st 05 12:26 AM
Formula: If 2 values (in a range of six) are >3 then TRUE, FALSE IFfunction Excel Discussion (Misc queries) 2 October 10th 05 10:34 AM


All times are GMT +1. The time now is 10:26 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"