seeking better solution to remove empty text string created by ""

astrojack98

New Member
Joined
Dec 27, 2012
Messages
1
I've been struggling to remove the empty text string created when I use "" as the false value in formulas. I think I found a way but I wanted to see if anyone has a more elegant solution, and one that would work as a macro.

I use the "if" formula to populate many of the cells on my spreadsheet and was using "" as the false value [ex: if(A2>0, "YES","")], and I need false cells to truly be empty. I learned from several threads on this site that the false cells are not truly empty; the equation leaves an empty text string in the false cells.

My current "work around" is to populate all false cells with "z" [ex: if(A2>0,"YES","z")]. I then use "find all" to find all cells with "z" (matching exact cell contents), hit "ctrl+A" to select all the "z" cells, and then hit "delete". This works - all the false cells will truly be empty, but it takes time and I don't think I can make it into a macro. Does anyone know of a better solution?
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Maybe this

Code:
Sub makeblank()
Dim c As Range
For Each c In ActiveSheet.UsedRange
    If c.Value = "" Then c.ClearContents
Next c
End Sub
 
Upvote 0
Welcome to the board

You might just let your IF formulas actually return the FALSE Boolean value.
=IF(A2>0,"Yes") <-Notice the False section is just omitted, it defaults to FALSE.
Then you can just use Autofilter to filter for FALSE values, and delete the rows.
And that can be put into a macro.
 
Upvote 0
I've been struggling to remove the empty text string created when I use "" as the false value in formulas. I think I found a way but I wanted to see if anyone has a more elegant solution, and one that would work as a macro.

I use the "if" formula to populate many of the cells on my spreadsheet and was using "" as the false value [ex: if(A2>0, "YES","")], and I need false cells to truly be empty. I learned from several threads on this site that the false cells are not truly empty; the equation leaves an empty text string in the false cells.

My current "work around" is to populate all false cells with "z" [ex: if(A2>0,"YES","z")]. I then use "find all" to find all cells with "z" (matching exact cell contents), hit "ctrl+A" to select all the "z" cells, and then hit "delete". This works - all the false cells will truly be empty, but it takes time and I don't think I can make it into a macro. Does anyone know of a better solution?
Give this macro a try...
Code:
Sub ClearEmptyStringCells()
  Dim R As Long, C As Long, FormulaArray As Variant, ValueArray As Variant
  ValueArray = ActiveSheet.UsedRange
  FormulaArray = ActiveSheet.UsedRange.Formula
  For R = 1 To UBound(ValueArray)
    For C = 1 To UBound(ValueArray, 2)
      If ValueArray(R, C) = "" Then FormulaArray(R, C) = ""
    Next
  Next
  ActiveSheet.UsedRange.Formula = FormulaArray
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,978
Messages
6,122,549
Members
449,089
Latest member
davidcom

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top