Extract Last part of the string

karthikgmkk

New Member
Joined
Jul 18, 2015
Messages
13
Hi,

I have values like below, where I have to extract the last part of the string in every value.

It would be great if you also can provide the formula for extracting 2 part of the string as well.

topnav-_-whatsnew-_-topbar
topnav-_-whatsnew-_-thisweek
topnav-_-designers-_-designera-z
topnav-_-clothing-_-dresses
topnav-_-sale-_-topbar
topnav-_-sale-_-clothing

<colgroup><col></colgroup><tbody>
</tbody>

Can you please help me with the formula?

Regards,
Karthik
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
If the separator is ALWAYS "-_-", write

Code:
Dim arr$()
arr = Split(s, [COLOR=#222222][FONT=Verdana]"-_-"[/FONT][/COLOR])

where s is your string. The arr array contains adequate parts of s.
 
Upvote 0
Hi,

Is this what you want?


Book1
ABCD
12 partslast part
2topnav-_-whatsnew-_-topbarwhatsnew-_-topbartopbar
3topnav-_-whatsnew-_-thisweekwhatsnew-_-thisweekthisweek
4topnav-_-designers-_-designera-zdesigners-_-designera-zdesignera-z
5topnav-_-clothing-_-dressesclothing-_-dressesdresses
6topnav-_-sale-_-topbarsale-_-topbartopbar
7topnav-_-sale-_-clothingsale-_-clothingclothing
Sheet7
Cell Formulas
RangeFormula
C2=MID(A2,FIND("-_-",A2)+3,255)
D2=MID(A2,FIND("^",SUBSTITUTE(A2,"-_-","^",2))+3,255)


Formulas copied down.
 
Upvote 0
Perfect !! It is working :)
You can also do this easily enough manually (no formulas required)...

1) Select the entire column with your data in it, press CTRL+H to bring up the replace dialog box, type "-_-" in the "Find what" field (without the quote marks), type "_" in the "Replace with" field (again, without the quote marks), click the "Options>>" button and make sure there are no check marks in the checkboxes, then click the "Replace All" button.

2) The column will still be highlighted so bring up the "Text To Columns" dialog box (Data tab, Data Tools panel), select "Delimited" and press the "Next" button, uncheck the checkboxes and then check the "Other" checkbox and put an underscore character in the blank field next to it, click the "Finish" button.
 
Upvote 0

Forum statistics

Threads
1,214,376
Messages
6,119,181
Members
448,871
Latest member
hengshankouniuniu

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