StarliteLemming
New Member
- Joined
- Jun 2, 2022
- Messages
- 12
- Office Version
- 2019
- Platform
- Windows
When using Excel to clean tabular data, one issue that often pops up is that VLOOKUP returns zero '0' for empty cells.
What is the best way to deal with this?
Why the Obvious is Unsatisfactory
The obvious thing to do is:
The problem with this should be fairly obvious: the complexity of the formula is doubled. Here, I've used a flexible way to specify the column, but there are cases where $A3 might be replaced with a complex expression.
Of course, I may be worried about nothing, but it feels cumbersome and inefficient for my computer.
Note that using an array formula is generally not an option because it's difficult to extend the table or insert rows.
Another Possibility
It occurred to me to wrap the VLOOKUP() in a SUBSTITUTE() like so:
but I don't think Excel understands that kind of regular expression in SUBSTITUTE().
Forcing an Error
Ideally, I want a zero value to force an error, as per:
but I can't think of anything that would work, where adding zero can work great in the inverse case.
Conclusion
Am I stuck with repeating the VLOOKUP() expression, or is there another way?
Thanks in advance!
PS: I suppose I could use VBA to create a UDF, but that seems like a lot of work, and is probably not portable to Google Sheets (for some projects).
What is the best way to deal with this?
Why the Obvious is Unsatisfactory
The obvious thing to do is:
Excel Formula:
=IF(VLOOKUP($A3, tblData, COLUMN(B3), FALSE) = "", "", VLOOKUP($A3, tblData, COLUMN(B3), FALSE))
The problem with this should be fairly obvious: the complexity of the formula is doubled. Here, I've used a flexible way to specify the column, but there are cases where $A3 might be replaced with a complex expression.
Of course, I may be worried about nothing, but it feels cumbersome and inefficient for my computer.
Note that using an array formula is generally not an option because it's difficult to extend the table or insert rows.
Another Possibility
It occurred to me to wrap the VLOOKUP() in a SUBSTITUTE() like so:
Excel Formula:
=SUBSTITUTE(VLOOKUP(...), "$0^", "")
Forcing an Error
Ideally, I want a zero value to force an error, as per:
Excel Formula:
=IFERROR(SOMETHING(VLOOKUP(...)), "")
Conclusion
Am I stuck with repeating the VLOOKUP() expression, or is there another way?
Thanks in advance!
PS: I suppose I could use VBA to create a UDF, but that seems like a lot of work, and is probably not portable to Google Sheets (for some projects).