lorikgator
New Member
- Joined
- Aug 26, 2014
- Messages
- 25
I've searched rather extensively but can only seem to find the OPPOSITE of what I'm trying to.
I want to use VBA to evaluate all of the cells in a given range on a sheet and delete the contents of any cells that have formulas that evaluate to ""
We are using this spreadsheet to upload to a system that uses XML to decide which columns to read on import. If it sees a value, it imports it, and if that value is "", it is of course recognizing the field as having content instead of being blank (because of course the content is ""). I need to get rid of all of the fields that evaluate to "" but, ideally, keep the formulas for the fields that evaluate to something other than "". I've been using "CLEAN" to cheat and just essentially copy and paste the values of the cells (and remove the ""), but I'd really like to keep the formulas for cells that evaluate to something useful if possible.
Any idea how this could be done in VBA?
Here's my "clean" code that's working fine. I was hoping maybe just an "if" statement to target only cells with a value of "" but I can't seem to get the syntax right, assuming that's possible:
Help much appreciated!
Lori
I want to use VBA to evaluate all of the cells in a given range on a sheet and delete the contents of any cells that have formulas that evaluate to ""
We are using this spreadsheet to upload to a system that uses XML to decide which columns to read on import. If it sees a value, it imports it, and if that value is "", it is of course recognizing the field as having content instead of being blank (because of course the content is ""). I need to get rid of all of the fields that evaluate to "" but, ideally, keep the formulas for the fields that evaluate to something other than "". I've been using "CLEAN" to cheat and just essentially copy and paste the values of the cells (and remove the ""), but I'd really like to keep the formulas for cells that evaluate to something useful if possible.
Any idea how this could be done in VBA?
Here's my "clean" code that's working fine. I was hoping maybe just an "if" statement to target only cells with a value of "" but I can't seem to get the syntax right, assuming that's possible:
Code:
Sub DeletingBlankFormulas()
Dim rng As Range
With ActiveSheet
Set rng = Application.Intersect(.UsedRange, .Cells.Resize(.Rows.Count - 12).Offset(12))
rng.Value2 = Evaluate("IF(ROW(" & rng.Address & "),CLEAN(" & rng.Address & "))")
On Error Resume Next
End With
End Sub
Help much appreciated!
Lori