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 |
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 |
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 |
All times are GMT +1. The time now is 01:52 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com