Format an NPI or EIN by its type

Keep an NPI as it is, and write an EIN like 02-3456789.

What you'll make

In Excel: EIN + 023456789 becomes 02-3456789.

The formula

The formula, with a numbered bracket under each part.
NumberPartWhat it doesResult so far
1A8The ID type: NPI or EIN."EIN"
2"NPI",B8For an NPI, shows the digits as they are.Not used for row 8
3"EIN",LEFT( … )For an EIN, adds a hyphen after two digits."02-3456789"
4"Review ID type"What the cell says for any other type.Not used for row 8
5SWITCH( … )Picks the part that matches the type."02-3456789"

Read it left to right. The digits are text, so zeros at the front stay. The IDs here are made-up.

=SWITCH(A8,"NPI",B8,"EIN",LEFT(B8,2)&"-"&RIGHT(B8,7),"Review ID type")

How to use it

Yellow bar at the top? Click Enable Editing.

  1. See it work. The Example tab shows 20 made-up examples with the formula already in.
  2. Use your own IDs. Paste each ID type and its digits into the green columns of the Template tab. The IDs fill in by themselves.
  3. Move them into your letter. Copy the results. Then use Paste Special and choose Values.

Before you send

This doesn't count digits. Check that each NPI has ten and each EIN has nine.

Microsoft's help: SWITCH function