Help with =LEFT Formula

bradjedis
4StarLounger
Posts: 538
Joined: 30 Mar 2010, 18:49
Location: United States

Help with =LEFT Formula

Post by bradjedis »

Greetings,

I have the following formula: =LEFT(A2,FIND("-",A2)-1). This works fine, except when I have a string such as 2345-1234-56789

I need to extract the first and second part of the string... 2345-1234. These could be more characters or fewer in each part between the dash, but the condition exists with having two dash's.

Thanks,

Brad

User avatar
HansV
Administrator
Posts: 78485
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Help with =LEFT Formula

Post by HansV »

Try

=TRIM(LEFT(SUBSTITUTE(A2, "-", REPT(" ", 255), 2), 255))
Best wishes,
Hans

bradjedis
4StarLounger
Posts: 538
Joined: 30 Mar 2010, 18:49
Location: United States

Re: Help with =LEFT Formula

Post by bradjedis »

Nice!


Thanks.

snb
4StarLounger
Posts: 575
Joined: 14 Nov 2012, 16:06

Re: Help with =LEFT Formula

Post by snb »

=LEFT(A1;FIND("-";A1;FIND("-";A1)+1)-1)

User avatar
rory
5StarLounger
Posts: 817
Joined: 24 Jan 2010, 15:56

Re: Help with =LEFT Formula

Post by rory »

If you have a current version of 365:

=TEXTBEFORE(A2,"-",2)
Regards,
Rory

bradjedis
4StarLounger
Posts: 538
Joined: 30 Mar 2010, 18:49
Location: United States

Re: Help with =LEFT Formula

Post by bradjedis »

Tried them all. ALl worked. Thanks!!