Can I use the FIND function to find two values in Excel

angelad66

New Member
Joined
Jun 30, 2022
Messages
2
Office Version
  1. 2016
Platform
  1. Windows
I have a string of characters in a cell that are separated by a "/" or a "-", for example,
TRD-/TYU/OPM
DE-/GFU/REA
MDDR/LMV/OPG
YTT/IKM

I only need the first characters of the string so I am using this formula, =LEFT(D2,FIND("-",D2)-1) which returns the following
TRD
DE
#VALUE!
#VALUE!

If I replace the "-" with "/" then I get
#VALUE!
#VALUE!
MDDR
YTT

How do a combine the two statements to work for all instances of "-" or "/" in my data?
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Welcome to the Board!

If every entry has either "-" or "/", then this should work:
Excel Formula:
=LEFT(D2,IFERROR(FIND("-",D2),FIND("/",D2))-1)
 
Upvote 0
How about
Excel Formula:
=LEFT(D2,FIND("-",SUBSTITUTE(D2,"/","-"))-1)
 
Last edited:
Upvote 0
Or

Excel Formula:
=LEFT(A1,MIN(SEARCH({"-","/"},A1&"-/")-1))
 
Upvote 0
Welcome to the MrExcel forum!

Try:

Book3
AB
1
2TRD-/TYU/OPMTRD
3DE-/GFU/READE
4MDDR/LMV/OPGMDDR
5YTT/IKMYTT
Sheet27
Cell Formulas
RangeFormula
B2:B5B2=LEFT(A2,MIN(FIND({"-","/"},A2&"-/"))-1)
 
Upvote 0
Lots of subtly different ways to approach this one!
 
Upvote 0

Forum statistics

Threads
1,215,222
Messages
6,123,706
Members
449,118
Latest member
MichealRed

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top