Excel
Replace VLOOKUP with XLOOKUP
VLOOKUP fails in two ways that show up on a real spreadsheet. Leave the fourth argument blank and Excel treats it as an approximate match, so the wrong row can come back with no warning. The third argument is a column count, so inserting a column in the middle changes the answer.
XLOOKUP takes the lookup column and the return column as two separate ranges. Insert a column and both ranges move with it.
Build it
-
Put the data in an Excel Table first. Select the range and press Ctrl+T (Cmd+T on a Mac). Name the table
Policieson the Table Design tab. Table names cannot contain spaces. -
In the cell that should show the insured, enter:
=XLOOKUP(E2, Policies[PolicyNumber], Policies[Insured], "Not on the bordereau") -
E2is the policy number you are matching. Change the column names to the ones on your table. -
Fill the formula down. You are not counting columns, so the formula does not care what order the columns are in.
Why the fourth argument matters
"Not on the bordereau" is the optional if_not_found argument. A policy that is not in the table shows that sentence instead of #N/A. That is the version you can email to someone who does not read formulas.
When you need every matching row
XLOOKUP returns the first match. If one policy number can sit on more than one row and you need all of them, use FILTER instead. There is a separate tip for that.
Exact match is the default. You do not pass FALSE or 0 the way you should with VLOOKUP. That is the whole reason it is the safer function for an account number.
On a copy of a sheet you already use, replace one VLOOKUP that returns a name with XLOOKUP. Then insert a column inside the old lookup range and confirm the result stays put.
XLOOKUP is in Microsoft 365 and Excel 2021. It is not in Excel 2016 or Excel 2019.
More Excel tips
List only the rows you mean with FILTER
FILTER spills the matching rows onto the sheet. =FILTER(Policies, Policies[State]="TX", "Nothing in force for TX") stays current when the table changes.
Excel · 4 minSplit a policy number without a helper column
TEXTBEFORE, TEXTAFTER, and TEXTSPLIT pull a policy number apart in the cell where you need the piece. No Flash Fill, no Text to Columns, no broken leftovers.
Excel · 3 minPut the data in a Table before you write formulas
Ctrl+T turns a range into an Excel Table. Formulas fill down, new rows are included, and you can write =SUM(Policies[Premium]) instead of a range that goes stale.