View Single Post
  #11   Report Post  
Posted to microsoft.public.excel.misc
Ron Rosenfeld Ron Rosenfeld is offline
external usenet poster
 
Posts: 5,651
Default return an empty string in VBA

On Tue, 07 Aug 2007 08:31:33 -0700, Dave F wrote:

I'm trying to use the following code to return an empty string in a
range of cells if any value in the range is FALSE:

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

The problem is this code returns the actual quote marks "" in the
cells, not an empty string. R is set as a variant.

What am I doing wrong?

Thanks.

Dave


It sounds as if you want to have an empty cell. If that is the case, try:


If R.Value = False Then R.clearcontents


--ron