Extract part URL up to 2nd sub directory or file path

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Hi,

Based on your description and works for your given samples:


Book1
AB
1http://company.sharepoint.com/teamsite/Subdirectory1/http://company.sharepoint.com/teamsite/Subdirectory1/
2http://company.sharepoint.com/teamsite/Subdirectory1/folderA/folder1/http://company.sharepoint.com/teamsite/Subdirectory1/
3http://company.sharepoint.com/teamsite/Subdirectory1/folderB/http://company.sharepoint.com/teamsite/Subdirectory1/
4http://company.sharepoint.com/teamsite/Subdirectory2/http://company.sharepoint.com/teamsite/Subdirectory2/
5http://company.sharepoint.com/teamsite/Subdirectory2/folderC/http://company.sharepoint.com/teamsite/Subdirectory2/
6http://company.sharepoint.com/teamsite/Subdirectory3/http://company.sharepoint.com/teamsite/Subdirectory3/
7http://company.sharepoint.com/teamsite/Subdirectory3/folderD/http://company.sharepoint.com/teamsite/Subdirectory3/
8http://company.sharepoint.com/teamsite/Subdirectory3/folderE/folder2http://company.sharepoint.com/teamsite/Subdirectory3/
Sheet372
Cell Formulas
RangeFormula
B1=TRIM(LEFT(SUBSTITUTE(A1,"/","/"&REPT(" ",LEN(A1)),5),LEN(A1)))


Formula copied down.
 
Upvote 0
Awesomeness Jtakw!! Much appreciated. It works perfectly but I realised I actually need it up to the 3rd subdirectory so I'm battling away trying to expand it. If you can help again, please do.

Thanks again.
 
Upvote 0
How about
=IFERROR(LEFT(A1,FIND("|",SUBSTITUTE(A1,"/","|",6))-1),A1)
 
Upvote 0
This is what I get


Excel 2013/2016
AB
1http://company.sharepoint.com/teamsite/Subdirectory1/http://company.sharepoint.com/teamsite/Subdirectory1/
2http://company.sharepoint.com/teamsite/Subdirectory1/folderA/folder1/http://company.sharepoint.com/teamsite/Subdirectory1/folderA
3http://company.sharepoint.com/teamsite/Subdirectory1/folderB/http://company.sharepoint.com/teamsite/Subdirectory1/folderB
4http://company.sharepoint.com/teamsite/Subdirectory2/http://company.sharepoint.com/teamsite/Subdirectory2/
5http://company.sharepoint.com/teamsite/Subdirectory2/folderC/http://company.sharepoint.com/teamsite/Subdirectory2/folderC
6http://company.sharepoint.com/teamsite/Subdirectory3/http://company.sharepoint.com/teamsite/Subdirectory3/
7http://company.sharepoint.com/teamsite/Subdirectory3/folderD/http://company.sharepoint.com/teamsite/Subdirectory3/folderD
8http://company.sharepoint.com/teamsite/Subdirectory3/folderE/folder2http://company.sharepoint.com/teamsite/Subdirectory3/folderE
data
Cell Formulas
RangeFormula
B1=IFERROR(LEFT(A1,FIND("|",SUBSTITUTE(A1,"/","|",6))-1),A1)
 
Upvote 0
Hi Fluff...

You're right, I've realised that when copy it down by double clicking the bottom right of the cell, it copies and updates the cell references but the result displayed is the same as first cell. Only if I click in he next cell below and hit enter does it update to show correct value. Any ideas formatting that's causing? it's in a table.
 
Upvote 0
Sounds like you have calculation set to manual.
Either hit F9, or on the Formula Tab, Calculation options, change to Automatic
 
Upvote 0
Sorted, cleared all the column formatting and it's worked instantly, didn't even need to copy it down. Thanks a million guys. Save me work.
 
Upvote 0
For future reference
While we do not prohibit Cross-Posting on this site, we do ask that you please mention you are doing so and provide links in each of the threads pointing to the other thread (see rule 13 here along with the explanation: Forum Rules).
This way, other members can see what has already been done in regards to a question, and do not waste time working on a question that may already be answered.

Cross posted https://www.excelforum.com/excel-fo...url-up-to-2nd-sub-directory-or-file-path.html
 
Upvote 0

Forum statistics

Threads
1,214,396
Messages
6,119,268
Members
448,881
Latest member
Faxgirl

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