简体   繁体   中英

Finding a character inside a string in Excel

I want to remove all the characters from a string expect whatever character is between a certain set of characters. So for example I have the input of Grade:2/2014-2015 and I want the output of just the grade, 2.

I'm thinking that I need to use the FIND function to grab whatever is between the : and the / , this also needs to work with double characters such 10 however I believe that it would work so long as the defining values with the FIND function are correct.

Unfortunately I am totally lost on this when using the FIND function however if there is another function that would work better I could probably figure it out myself if I knew what function.

It's not particularly elegant but =MID(A1,FIND(":",A1)+1,FIND("/",A1) - FIND(":",A1) - 1) would work.

MID takes start and length, FIND returns the index of a given character.

Edit: As pointed out, "Grade:" is fixed length so the following would work just as well: =MID(A1,7,FIND("/",A1) - 7)

You could use LEFT() to remove "Grade:"

And then use and then use LEFTB() to remove the year.

Look at this link here. This is the way I would go about it.

=SUBSTITUTE(SUBSTITUTE(C4, "Grade:", ""), "/2014-2015", "")

where C4 is the name of your cell.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM