Avatar of StevenPMoffat
StevenPMoffat

asked on 

Extract SubString from Middle of string

I need a simple function that will extract the substring that starts at position 5 and includes up to the first "-".

For Instance:
With
ABC-System1-012345960    I Get System1
ABC-A-34509   I get A.

Microsoft Excel

Avatar of undefined
Last Comment
StevenPMoffat
Avatar of rspahitz
rspahitz
Flag of United States of America image

How about this:

=Mid(A1, 5, Find("-", A1, 6)-5)
ASKER CERTIFIED SOLUTION
Avatar of rspahitz
rspahitz
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of rspahitz
rspahitz
Flag of United States of America image

If the location of the first dash will change, it needs to get a tiny bit more complex:

Basically replace each 5 with a find:

=MID(A1, FIND("-",A1)+1, FIND("-", A1 & "-",FIND("-",A1)+1)-FIND("-",A1)-1)
Avatar of jerrypd
jerrypd
Flag of United States of America image

here you go!
=MID(A1,5,FIND("-",A1,5)-5)
---Assuming A1 is your value


Avatar of StevenPMoffat
StevenPMoffat

ASKER

Thank You
Microsoft Excel
Microsoft Excel

Microsoft Excel topics include formulas, formatting, VBA macros and user-defined functions, and everything else related to the spreadsheet user interface, including error messages.

144K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo