Formula to Target Specific Section Within a URL

censo

Board Regular
Joined
Dec 25, 2015
Messages
161
Office Version
  1. 2013
Platform
  1. Windows
Hello,

I have a semi-successful solution to my problem. The formula below extracts the item number from a URL but only when the URL is "clean". If the URL has text within it as shown in cell A3, I get incorrect results.

In the table below, the first output is correct but the second is not. Column C shows the correct desired output.

What modification to this formula would target everything present after the last forward "/" slash but before the ".ip"?


Excel 2013 32 bit
ABC
2https://www.samsclub.com/sams/118235.ipSAM-118235SAM-118235
3https://www.samsclub.com/sams/oif-vertical-file-cabinet-4-drawer-economy-letter-26-1-2-black/prod5380361.ipSAM-black/prod5380361SAM-prod5380361
Sheet1
Cell Formulas
RangeFormula
B2=IF(A2<>"","SAM-"&LEFT(TRIM(RIGHT(SUBSTITUTE(A2,"/sams/",REPT(" ",20)),20)),LEN(TRIM(RIGHT(SUBSTITUTE(A2,"/sams/",REPT(" ",20)),20)))-3),"")


Thanks
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
See if this solves your problem.

Excel Workbook
AB
2https://www.samsclub.com/sams/118235.ipSAM-118235
3https://www.samsclub.com/sams/oif-vertical-file-cabinet-4-drawer-economy-letter-26-1-2-black/prod5380361.ipSAM-prod5380361
Extract from URL




Also, if you are using one of the HTML makers suggested in this site (see link in my signature block below) you should update to the latest version & I think your screen shots will look a lot better. :)
 
Last edited:
Upvote 0
That did the trick, Peter. Thanks for your contribution and for the note about the updated HTML makers. I was wondering my table came out looking so funky, it's all good now!

Is there a way to mark this thread as SOLVED or is that not necessary?
 
Upvote 0
That did the trick, Peter. Thanks for your contribution and for the note about the updated HTML makers. I was wondering my table came out looking so funky, it's all good now!
No problem, glad it helped.


Is there a way to mark this thread as SOLVED or is that not necessary?
What you have written is fine. It tells us you are satisfied, but it is not uncommon for a better solution to come along even after an OP says their problem is solved and we want to keep it that way. :)
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,827
Messages
6,181,194
Members
453,021
Latest member
pingpong7117

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