SKU Generator From Various URLs - Different Syntax

censo

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

The functions below create a custom SKU based on a hard-coded supplier and its respective URL syntax


Excel 2013 32 bit
ABC
1ExampleSUPP URLCUSTOM SKU Output
21https://www.walmart.com/ip/33857317WAL-33857317
32https://www.walmart.com/ip/Mainstays-Metal-Canopy-Bed-Multiple-Colors-Multiple-Sizes/126889322WAL-126889322
4
53https://www.costco.com/Aquaterra-Spas-Ventura-96-jet%2c-6-person-Spa.product.100355896.htmlCOS-100355896
64https://www.costco.com/Urban-Islands-304-Stainless-Steel-5-burner-Grill.product.100075481.htmlCOS-100075481
7
85https://www.samsclub.com/sams/118235.ipSAM-118235
96*https://www.samsclub.com/sams/oif-vertical-file-cabinet-4-drawer-economy-letter-26-1-2-black/prod5380361.ipSAM-black/prod5380361
107*https://www.samsclub.com/sams/chair-leather-coil-b/prod12930214.ip?xid=cat1838-offi:carousel-save-on-office-chairs:2:4SAM-on-office-chairs:
DATA
Cell Formulas
RangeFormula
C2=IF(B2<>"","WAL-"&TRIM(RIGHT(SUBSTITUTE(B2,"/",REPT(" ",LEN(B2))),LEN(B2))+0),"")
C3=IF(B3<>"","WAL-"&TRIM(RIGHT(SUBSTITUTE(B3,"/",REPT(" ",LEN(B3))),LEN(B3))+0),"")
C5=IF(B5<>"","COS-"&LEFT(TRIM(RIGHT(SUBSTITUTE(B5,".product.",REPT(" ",20)),20)),LEN(TRIM(RIGHT(SUBSTITUTE(B5,".product.",REPT(" ",20)),20)))-5),"")
C6=IF(B6<>"","COS-"&LEFT(TRIM(RIGHT(SUBSTITUTE(B6,".product.",REPT(" ",20)),20)),LEN(TRIM(RIGHT(SUBSTITUTE(B6,".product.",REPT(" ",20)),20)))-5),"")
C8=IF(B8<>"","SAM-"&LEFT(TRIM(RIGHT(SUBSTITUTE(B8,"/sams/",REPT(" ",20)),20)),LEN(TRIM(RIGHT(SUBSTITUTE(B8,"/sams/",REPT(" ",20)),20)))-3),"")
C9=IF(B9<>"","SAM-"&LEFT(TRIM(RIGHT(SUBSTITUTE(B9,"/sams/",REPT(" ",20)),20)),LEN(TRIM(RIGHT(SUBSTITUTE(B9,"/sams/",REPT(" ",20)),20)))-3),"")
C10=IF(B10<>"","SAM-"&LEFT(TRIM(RIGHT(SUBSTITUTE(B10,"/sams/",REPT(" ",20)),20)),LEN(TRIM(RIGHT(SUBSTITUTE(B10,"/sams/",REPT(" ",20)),20)))-3),"")

<insert excel="" file="" here="">
(I don't know why this is coming out all multi-colored)

THE CHALLENGE

The above solution works fine* for a single supplier on a sinble tab; however, when working with various suppliers on the sam tab, challenges are created which are:

- SKU prefixes cannot be hardcoded in the function for a single supplier using the current method (i.e., "WAL")
- Different suppliers have different URL syntax


THE DESIRED RESULT

A two-pronged function that:

- identifies the supplier by URL, and builds a SKU beginning with a prefix (ex., "WAL", "COS", "SAM"). The supplier prefix will always be 3 characters in length (references an array - preferably a named list, such as "SUPP_PREFIX")

- then returns the item# from that specific supplier's URL and concatenates the SKU properly with a hyphen separating the two returned values (ex. "WAL-1234567")


SUPPORTING DETAILS

The ability to identify the supplier from a URL will ALWAYS be in between "www." and ".com" - the beginning portion of the URL. This syntax will always be constant and true.

Context Examples:
<supplier><supplier><supplier><supplier><supplier><supplier><supplier><supplier><supplier><supplier><supplier><supplier>www.supplier.com
http://www.supplier.com
https://www.supplier.com

Content Examples:
<item#>www.walmart.com/ip/ITEM#
"walmart" identifies as "WAL"

<item#>https://www.samsclub.com/sams/ITEM#.ip
"samsclub" identifies as "SAM"

<item#>https://www.costco.com/.product.ITEM#.html
"costco" identifies as "COS"

As alluded to above, the function would then reference a secondary array based on:

- a particular supplier's name, and then
- recognize that supplier's syntax to know where to extract the specific item#


SPECIFIC ITEM# LOCATION

The exact location of the suppliers' item# appear in the examples provided above (Content Examples).

I have what appears to be working solutions for Walmart and Costco.

With Sam's Club however, I get mixed results*. On the referenced Excel table above, Examples 6 & 7 return inconsistent results. The output should only be the supplier prefix, hyphen, item# (Ex. SAM-1234567).

Note - the correct SKU output for Example 6 should be: SAM-prod5380361 because that's what appears between the last forward slash and ".ip"

What modification to this function would target only what appears between the last foward slash and ".ip"?


PUTTING IT ALTOGETHER

Functions are not my strong suit but I try my best to understand what they do and with the help of this community, I've been successful in piecing together what works for previous projects.

Below is a function that successfully worked for creating hyperlinks based on evaluating the name of a carrier in the URL. I believe that in this function solves the question about how to identify the supplier in order to determine the supplier prefix but I need help tying it altogether to go a step further and properly concatenate a perfect SKU just by evaluating a URL.


Code:
=IF(A5<>"",VLOOKUP(IF(ISNUMBER(FIND("www.",A5)),MID(A5,FIND("www.",A5)+4,IF(ISNUMBER(FIND(".com",A5,9)),FIND(".com",A5,9),LEN(A5)+1)-FIND("www.",A5)-4),MID(A5,FIND("//",A5)+2,IF(ISNUMBER(FIND("/",A5,9)),FIND("/",A5,9),LEN(A5)+1)-FIND("//",A5)-2)),SUPP_PREFIX,2,0)


My attempts can be seen on the "Reference" tab and the two named lists I've created there; "SUPP_PREFIX" and "SUPP_ITEM".

I see a flaw right away in that in the "Reference" tab specific cell references are coded in and I just don't know how to make that "neutral" or "variable" for a lack of better words.


Excel 2013 32 bit
AB
1SUPPLIERSUPP CODE
2walmartWAL
3samsclubSAM
4costcoCOS
5
6
7
8
9
10SUPP CODESUPP FUNCTION
11WALTRIM(RIGHT(SUBSTITUTE(A1,"/",REPT(" ",LEN(A1))),LEN(A1))+0)
12SAMLEFT(TRIM(RIGHT(SUBSTITUTE(A1,"/sams/",REPT(" ",20)),20)),LEN(TRIM(RIGHT(SUBSTITUTE(A1,"/sams/",REPT(" ",20)),20)))-3)
13COSLEFT(TRIM(RIGHT(SUBSTITUTE(A1,".product.",REPT(" ",20)),20)),LEN(TRIM(RIGHT(SUBSTITUTE(A1,".product.",REPT(" ",20)),20)))-5)
REFERENCE





I hope this write-up is chocked full of details to clearly express what I need done and I'm happy to actively engage and try solutions you propose.


Thanks!</item#></item#></item#></supplier></supplier></supplier></supplier></supplier></supplier></supplier></supplier></supplier></supplier></supplier></supplier></insert>
 
Last edited:

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.

Forum statistics

Threads
1,223,958
Messages
6,175,642
Members
452,663
Latest member
MEMEH

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