Return part of cell URL string based on number of '/' values

chive90

New Member
Joined
May 3, 2023
Messages
35
Office Version
  1. 2016
In Column C I have various URL's, however I only wish to display part of the URL string in Column B.

The URL string in Column C has various '/', but I would only like the URL string up to 5 '/' displayed in Column B.

Example Column C : http://toplevel/childlevel/name/123/456/abc/def/
Desired entry in Column B: http://toplevel/childlevel/name/

Is there a formula I can use in Column B to display what I am looking for?

Thanks
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
How about
Excel Formula:
=LEFT(C2,FIND("^",SUBSTITUTE(C2,"/","^",5)))
 
Upvote 1
Solution
How about
Excel Formula:
=LEFT(C2,FIND("^",SUBSTITUTE(C2,"/","^",5)))

Hey thanks that works great!

Related to this, is there a formula I can use to find how many entries contain the outputted URL?
e.g. now in B2 thanks to your formula I have http://toplevel/childlevel/name/ - I want to use this as a find/countif to return a count of how many records contain this URL - caveat though is that I don't want to match the exact URL, it also needs to count any that are longer, e.g. http://toplevel/childlevel/name/123/456/abc/def/

I tried using a simple countif and using the string in B2, but it only returns a count of those that exactly match B2, and not any that contain the first part of B2 and the longer string e.g. http://toplevel/childlevel/name/123/456/abc/def/

Is there a way to modify a countif to return any that match the first part of the string?

Thanks
 
Upvote 0
You can use
Excel Formula:
=countifs(a:a,b2&"*")
 
Upvote 1
You can use
Excel Formula:
=countifs(a:a,b2&"*")

Thanks so much! Care to explain to an amateur like me how this works? What is the &"*" saying, is it that it must match B2 and any additional string after?

Thank you
 
Upvote 0

Forum statistics

Threads
1,215,340
Messages
6,124,386
Members
449,155
Latest member
ravioli44

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