One of our customers presented us with this problem. He had an Excel workbook containing address data, with the usual Address 1 and Address 2 fields. He wanted to use VLOOKUP to extract the first line of the address, but he noticed that in some cases the Address 1 field had been left blank and the first line of the address had been written in the Address 2 field instead.
Here’s a mockup example that I created:
You want to use VLOOKUP to extract the first line of the address into column H, but you want your formula to return the address from column D if the value in column C is blank.
Solving the problem with the IF function
The IF function allows you to solve this problem, though IF functions can be difficult to understand.
The IF and VLOOKUP functions are both fully explained in our Expert Skills Books and E-books.
The formula to solve this problem is:
This formula works as follows:
IF the value in the 3rd column of the Customer table is blank, return the value in the 4th column of the Customer table, otherwise return the 3rd column of the Customer table.
You can download a copy of the sample workbook to see the formulas in action.
These are the only up-to-date Excel books currently published and includes the new Dynamic Arrays features.
They are also the only books that will teach you absolutely every Excel skill including Power Pivot, OLAP and DAX.