Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel function question 2

Status
Not open for further replies.

des0929

Technical User
Nov 11, 2003
6
US
What function would I use to take a string and parse it the following way:

Original string: 20BPP0355
1. Need to find the "BPP" and bring every value to the
right of "BPP" into a new field:

New string: 0355


 
Assuming that your string "20BPP0355" is located in cell A1:

=MID(A1,SEARCH("BPP",A1)+3,LEN(A1))

Should work for you!



Peace!! [americanflag] [peace] [americanflag]

Mike

Didn't get the answers that you wanted? Then . . . Click Here
 
With Data in Col A starting A1, in B1 and copied down:-

=RIGHT(A1,LEN(A1)-(LEN("BPP")+(FIND("BPP",A1)-1)))

Regards
Ken..............

----------------------------------------------------------------------------
[peace]It's easier to beg forgiveness than ask permission[2thumbsup]

----------------------------------------------------------------------------
 
Hi ah - That will only work if every string is of the same format and length as the one in the example, but if that were the case then the OP may as well use Data / Text To Columns / Fixed Width.

Regards
Ken..............

----------------------------------------------------------------------------
[peace]It's easier to beg forgiveness than ask permission[2thumbsup]

----------------------------------------------------------------------------
 
Sorry Higgins,

but what if the string is 20[COLOR=red yellow]5[/color]BPP0355? Then yours won't work.

;-)



Peace!! [americanflag] [peace] [americanflag]

Mike

Didn't get the answers that you wanted? Then . . . Click Here
 
Here's another way:

=REPLACE(A1,1,SEARCH("BPP",A1)+2,"")

;-)



Peace!! [americanflag] [peace] [americanflag]

Mike

Didn't get the answers that you wanted? Then . . . Click Here
 
Oops,

=REPLACE(A1,1,SEARCH("BPP",A1)[COLOR=green yellow]+LEN("BPP")-1[/color],"")

and my other should have read:

=MID(A1,SEARCH("BPP",A1)+[COLOR=green yellow]LEN("BPP")[/color],LEN(A1))

[blush]



Peace!! [americanflag] [peace] [americanflag]

Mike

Didn't get the answers that you wanted? Then . . . Click Here
 
My 2 cents :)

=RIGHT(A1,LEN(A1)-(FIND("B",A1)+2))

[Blue]Blue[/Blue] [Dragon]

If I wasn't Blue, I would just be a Dragon...
 
Not only was I the 3rd to press "Submit," but my answer wasn't even right! [blush]

What can I say, it's been a along day and my brain hurts - I clearly under-thought this one.

John
 
LOL - The times I've wished I could take back pressing that damned Submit button!!! :)

Hi Blue - Same caveat as with ah's - What if all the data is not of that exact same format and contains other Bs?

eg 2B5BPP0355

Regards
Ken...................

----------------------------------------------------------------------------
[peace]It's easier to beg forgiveness than ask permission[2thumbsup]

----------------------------------------------------------------------------
 
Always true as usual Ken, I just kept the KISS moment in case it was that simple...



[Blue]Blue[/Blue] [Dragon]

If I wasn't Blue, I would just be a Dragon...
 
:)

----------------------------------------------------------------------------
[peace]It's easier to beg forgiveness than ask permission[2thumbsup]

----------------------------------------------------------------------------
 
Another way to do this, would be to use Excel's Replace Tool (i.e. Edit->Replace... [or Ctrl+H])

In the "Find What" field enter "*BPP"
' The asterisk " * " before "BPP" tells Excel to replace everything BEFORE "BPP".

In the "Replace With" field Blank or an apostrophy " ' "
' Using the example string, this would return 0355, which Excel will automatically recognize as a number and display just 355. If you want the "0355" to be shown, then enter an apostrophe " ' " in the "Replace With" field.

Just another option. ;-)

Peace!! [americanflag] [peace] [americanflag]

Mike

Didn't get the answers that you wanted? Then . . . Click Here
 
<g> You could also..........

Click on every cell, hit F2, hit left arrow repeatedly until you get to the B before the PP, then, right arrow back to the last P, then backspace back to the start, type apostrophe and then hit enter. then move to the next cell and repeat

It's possible I'd go with one of the other responses before resorting to this one though :)

Regards
Ken...................

----------------------------------------------------------------------------
[peace]It's easier to beg forgiveness than ask permission[2thumbsup]

----------------------------------------------------------------------------
 
LOL [rofl]

Many Roads Lead to Rome (or something) ;-)



Peace!! [americanflag] [peace] [americanflag]

Mike

Didn't get the answers that you wanted? Then . . . Click Here
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top