# Can anyone please explain why my Mid formula is not working?

Options
✭✭✭✭

I am trying to pull the 5 digit number ID in the middle of this text string. My formula works for the ones labled CTV however for everything else it is an #Incorrect Argument. Any help would be greatly appreciated

=IFERROR(MID([Campaign Name]@row, FIND("_CTV", [Campaign Name]@row) - 5, 5), MID([Campaign Name]@row, FIND("_OLV", [Campaign Name]@row) - 5, 5, MID([Campaign Name]@row, FIND("_DISPLAY", [Campaign Name]@row) - 5, 5, MID([Campaign Name]@row, FIND("_HIS", [Campaign Name]@row) - 5, 5), MID([Campaign Name]@row, FIND("_AUDIO", [Campaign Name]@row - 5, 5)))))

Example of text strings where I need 24012, 23928, and 23836 extracted

Mazda_TTD_SO_ORLANDO-DAYTONA BCH-MELBRN_SPORT MAZDA NORTH_24012_CTV_MULTI_2023

Mazda_TTD_SO_ORLANDO-DAYTONA BCH-MELBRN_JENKINS MAZDA_23928_OLV_MULTI_2023

Mazda_TTD_SO_RALEIGH-DURHAM_SPORT DURST MAZDA_23836_DISPLAY_MULTI_2023

• ✭✭✭✭✭✭
Options

It looks like the number is always after the 5th underscore. If this is correct then this formula should pull it for you:

=MID([Campaign Name]@row, FIND(CHAR(1), SUBSTITUTE([Campaign Name]@row, "_", CHAR(1), 5)) + 1, 5)

Hope this helps!

• ✭✭✭✭✭✭
Options

It looks like the number is always after the 5th underscore. If this is correct then this formula should pull it for you:

=MID([Campaign Name]@row, FIND(CHAR(1), SUBSTITUTE([Campaign Name]@row, "_", CHAR(1), 5)) + 1, 5)

Hope this helps!

## Help Article Resources

Want to practice working with formulas directly in Smartsheet?

Check out the Formula Handbook template!