With the help of the online community, I've been piecing together solutions to a moderately complex solution. I'm hoping this post can tie them all together.
This first function identifies the name of a supplier based on its URL and creates a unique 3-character code based on a lookup table. This one function applies to any URL.
The next set of functions properly identifies the item number (a specific section of a website's URL). Note however that each website has its own unique syntax; therefore, for this function to dynamically work, it must reference an array that tells it which subsequent function to use to yield the desired result (based on supplier URL).
The arrays are found on the REFERENCE tab
The arrays are named ranges:
SUPP_PREFIX
SUPP_ITEM
A challenge I see is that in the SUPP_ITEM array, cell references are hard-coded into the listed functions (which worked when I used them individually because when I would pull the functions down, the cell references would auto-update). In this case however, how can instances of cell reference "A1" be made to vary or apply to the line in which it is being executed upon?
Tying the two main functions to generate a SKU dynamically based on a given supplier URL is the end goal.
Thanks for your input!
This first function identifies the name of a supplier based on its URL and creates a unique 3-character code based on a lookup table. This one function applies to any URL.
Book1 | ||||
---|---|---|---|---|
A | B | |||
1 | SUPP URL | SUPP CODE | ||
2 | https://www.walmart.com/ip/33857317 | WAL | ||
3 | https://www.samsclub.com/sams/118235.ip | SAM | ||
4 | https://www.costco.com/Aquaterra-Spas-Ventura-96-jet%2c-6-person-Spa.product.100355896.html | COS | ||
DATA |
Cell Formulas | ||
---|---|---|
Range | Formula | |
B2 | =IF(A2<>"",VLOOKUP(IF(ISNUMBER(FIND("www.",A2)),MID(A2,FIND("www.",A2)+4,IF(ISNUMBER(FIND(".com",A2,9)),FIND(".com",A2,9),LEN(A2)+1)-FIND("www.",A2)-4),MID(A2,FIND("//",A2)+2,IF(ISNUMBER(FIND("/",A2,9)),FIND("/",A2,9),LEN(A2)+1)-FIND("//",A2)-2)),SUPP_PREFIX,2,0)) |
Named Ranges | ||
---|---|---|
Name | Refers To | Cells |
SUPP_PREFIX | =REFERENCE!$A$1:$B$4 |
The next set of functions properly identifies the item number (a specific section of a website's URL). Note however that each website has its own unique syntax; therefore, for this function to dynamically work, it must reference an array that tells it which subsequent function to use to yield the desired result (based on supplier URL).
Book1 | ||||
---|---|---|---|---|
D | E | |||
1 | SUPP URL | ITEM NUMBER | ||
2 | https://www.walmart.com/ip/33857317 | 33857317 | ||
3 | https://www.samsclub.com/sams/118235.ip | 118235 | ||
4 | https://www.costco.com/Aquaterra-Spas-Ventura-96-jet%2c-6-person-Spa.product.100355896.html | 100355896 | ||
DATA |
Cell Formulas | ||
---|---|---|
Range | Formula | |
E2 | =TRIM(RIGHT(SUBSTITUTE(D2,"/",REPT(" ",LEN(D2))),LEN(D2))+0) | |
E3 | =TRIM(RIGHT(SUBSTITUTE(LEFT(D3,LEN(D3)-3),"/",REPT(" ",100)),100)) | |
E4 | =SUBSTITUTE(TRIM(RIGHT(SUBSTITUTE(D4,".product.",REPT(" ",99)),98)),".html","") |
The arrays are found on the REFERENCE tab
Book1 | ||||
---|---|---|---|---|
A | B | |||
1 | SUPP NAME | SUPP CODE | ||
2 | walmart | WAL | ||
3 | samsclub | SAM | ||
4 | costco | COS | ||
5 | ||||
6 | SUPP CODE | SUPP FUNCTION | ||
7 | WAL | TRIM(RIGHT(SUBSTITUTE(A1,"/",REPT(" ",LEN(A1))),LEN(A1))+0) | ||
8 | SAM | TRIM(RIGHT(SUBSTITUTE(LEFT(A1,LEN(A1)-3),"/",REPT(" ",100)),100)),"") | ||
9 | COS | SUBSTITUTE(TRIM(RIGHT(SUBSTITUTE(A1,".product.",REPT(" ",99)),98)),".html",""),"") | ||
REFERENCE |
The arrays are named ranges:
SUPP_PREFIX
SUPP_ITEM
A challenge I see is that in the SUPP_ITEM array, cell references are hard-coded into the listed functions (which worked when I used them individually because when I would pull the functions down, the cell references would auto-update). In this case however, how can instances of cell reference "A1" be made to vary or apply to the line in which it is being executed upon?
Tying the two main functions to generate a SKU dynamically based on a given supplier URL is the end goal.
Book1 | ||||
---|---|---|---|---|
A | B | |||
7 | SUPP URL | DESIRED OUTCOME | ||
8 | https://www.walmart.com/ip/33857317 | WAL-33857317 | ||
9 | https://www.samsclub.com/sams/118235.ip | SAM-118235 | ||
10 | https://www.costco.com/Aquaterra-Spas-Ventura-96-jet%2c-6-person-Spa.product.100355896.html | COS-100355896 | ||
DATA |
Thanks for your input!
Last edited: