Read the HL7 field separator from MSH

Take the separator each feed really uses, not an assumed pipe.

What you'll make

In Excel: MSH|^~\&|LAB|SITEA becomes |.

The formula

The formula, with a numbered bracket under each part.
NumberPartWhat it doesResult so far
1OR(LEFT(A8,3)<>"MSH",LEN(A8)<4)Checks the cell isn't MSH or is too short.FALSE
2"Review MSH prefix"What the cell says when part 1 is TRUE.Not used for row 8
3MID(A8,4,1)Takes the fourth character, right after MSH."|"
4IF( … )Uses part 2 when part 1 is TRUE, else part 3."|"

Read it left to right. It reads only the field separator, not the whole message.

=IF(OR(LEFT(A8,3)<>"MSH",LEN(A8)<4),"Review MSH prefix",MID(A8,4,1))

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 segments. Paste one MSH segment per row into the green column of the Template tab. The separator fills in by itself.
  3. Move them into your letter. Copy the results. Then use Paste Special and choose Values.

Before you send

Keep the original segment as it is. The other separators come from the next field, so check those separately.

Microsoft's help: MID function