I have a pretty simple spreadsheet. I'm using XLOOKUP to pull data from two sheets within one workbook, based on the email address. The formula works and inputs the correct date for the email address. However, if nothing exists in the field, I want the field to remain blank. The output ends up being an empty date of 1/0/00. If I don't have the cells formatted as a date, the dates come in as numbers and I get a 0 for those empty fields.
=XLOOKUP(F2,'Opt Outs'!A:A,'Opt Outs'!B:B,,0,1)
It does not matter what I put in the if_not_found field, it returns the 1/0/00 date. I would like for it to remain empty. Any suggestions?
Hi Ashley,
On row 2 you are looking up [email protected] and this is found in ColA of the Opt Outs sheet. So XLOOKUP is returning what it finds in the column you specify e.g.
=XLOOKUP(F2,'Opt Outs'!A:A,'Opt Outs'!E:E,,0,1)
returns the value in Column E which is an empty cell so XLOOKUP is returning 0.
You are asking XLOOKUP to find a value in Col A which it is doing, but there's no way to tell it not to return what it finds in Col E if that cell in Col E is empty.
If you want it to return 'nothing' you could put a space character into the 'empty' cells on the Opt Out pages, or a better solution would be to use a custom format on the cells on the Complete List sheet to not display 0. Something like this
d/mm/yyyy;;;
Also, you need to explicitly specify what to return if the lookup is not found e.g.
=XLOOKUP(F2,'Opt Outs'!A:A,'Opt Outs'!E:E,"",0,1)
Regards
Phil
Hi Philip,
Thank you for responding. I have tried using the "" for the if_not_found, but it will always default to the 1/0/00 or 0. I will try the custom formatting to see if that solves the problem. Unfortunately, using the space doesn't work either because there is another sheet that creates counts for the lists.
Thanks,
Ashley
Hi Ashley,
As the email address is being found, XLOOKUP will return something, so specifying "" for if_not_found is not applicable in such cases as something is found.
So using the custom format to not display 0 is the solution.
regards
Phil
I had the same issue and saw the posts from Ashley and Philip. Here's what I found elsewhere:
File, Options, Advanced, Display options for this worksheet, uncheck "Show a zero in cells that have zero value"
It will "blank" any cell with just a zero - not just the ones returned by lookups. That wasn't an issue for my purposes.
Regards,
David