Return empty cell from formula in Excel
excel, excel-formula
Solution
You're going to have to use `VBA`, then. You'll iterate over the cells in your range, test the condition, and delete the contents if they match.
Something like:
For Each cell in SomeRange
If (cell.value = SomeTest) Then cell.ClearContents
Next
Problem
I need to return an empty cell from an Excel formula, but it appears that Excel treats an empty string or a reference to an empty cell differently than a true empty cell. So essentially I need something like ``` =IF(some_condition,EMPTY(),some_value) ``` I tried to do things such as ``` =IF(some_condition,"",some_value) ``` and ``` =IF(some_condition,,some_value) ``` and assuming B1 is an empty cell ``` =IF(some_condition,B1,some_value) ``` but none of these appear to be true empty cells, I'm guessing because they are the result of a formula. Is there any way to populate a cell if and only if some condition is met and otherwise keep the cell truly empty? EDIT: as recommended, I tried to return NA(), but for my purposes this did not work either. Is there a way to do this with VB? EDIT: I am building a worksheet that pulls in data from other worksheets that is formatted to the very specific demands of an application that imports the data into a database. I do not have access to change the implementation of this application, and it fails if the value is "" instead of actually empty.