Dynamic Hyperlink Creator

censo

Board Regular
Joined
Dec 25, 2015
Messages
161
Office Version
  1. 2013
Platform
  1. Windows
I have an existing function that creates a hyperlink because the syntax of that URL is baked into the function. This works perfectly fine for a single website; however, the solution becomes obsolete and inaccurate when multiple websites are thrown into the mix.


In the sample below, Column A is the source data and Column B is the desired result with the use of said function.


Book1
AB
1SKUSUPP PAGE
2WAL-22880494http://www.walmart.com/ip/22880494
3WAL-12443829http://www.walmart.com/ip/12443829
4
5
6SKUDESIRED RESULT (MIX OF ALL SUPPLIERS)
7SAM-prod15680245https://www.samsclub.com/sams/prod15680245.ip
8SAM-prod17580146https://www.samsclub.com/sams/prod17580146.ip
9COS-100415587https://www.costco.com/.product.100415587.html
10COS-100376396https://www.costco.com/.product.100376396.html
11WAL-22880494http://www.walmart.com/ip/22880494
12WAL-12443829http://www.walmart.com/ip/12443829
DATA
Cell Formulas
RangeFormula
B2=HYPERLINK("http://www.walmart.com/ip/"&MID(A2,5,FIND("-",A2&"-",5)-5))



The function successfully extracts the item # from the SKU and concatenates it with a pre-defined syntax, but what I need it to do now is the following:


#1 - Identify the SUPP prefix (will ALWAYS be the first 3 characters of the SKU)


#2 - refer to a lookup table to find the supp code and use the syntax associated with the supplier it found


#3 - Within the syntax it found, find the instance where the phrase "ITEM" is present and replace it with the item number extracted


Book1
AB
1SUPP CODESUPP SYNTAX
2WALhttp://www.walmart.com/ip/ITEM
3SAMhttps:www.samsclub.com/sams/ITEM.ip
4COShttps://www.costco.com/.product.ITEM.html
REFERENCE



I'm not too versed in functions above my current level of understanding but I made a valiant attempt anyway. I think where the cell reference "A2" is present the MID function below should be inserted for one part but then another function like =LEFT(A2,3) should be used to identify the supplier somewhere else - but yea, that didn't work for me


Here are the functions that I think need to be in play and need to be joined together successfully


Code:
=LEFT(A2,3)
Identifies the Supplier


Code:
=MID(A2,5,FIND("-",A2&"-",5)-5)
Extracts the Item Number from the SKU


Code:
=HYPERLINK(REPLACE(VLOOKUP(A2,SUPP_SYNTAX,2,0),FIND("ITEM",(VLOOKUP(A2,SUPP_SYNTAX,2,0))),4,A2))
Finds the correct syntax and replaces "ITEM" with the correct Item Number from the SKU


I feel like I'm close, what am I missing?


Thanks.
 
Last edited:

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Try:

=HYPERLINK(SUBSTITUTE(VLOOKUP(LEFT(A2,3),Supp_syntax,2,0),"ITEM",MID(A2,5,99)))
 
Upvote 0
How about this? Col K contains the SUPP SYNTAX in the lookup table, and Col J contains the SUPP CODE.

=HYPERLINK(REPLACE(INDEX($K$3:$K$5,MATCH(LEFT(A7,3),$J$3:$J$5,0)),FIND("ITEM",INDEX($K$3:$K$5,MATCH(LEFT(A7,3),$J$3:$J$5,0))),4,RIGHT(A7,LEN(A7)-4)))

I tried it with VLOOKUP, but it was returning the wrong result for "SAM". And the lookup table for VLOOKUPs have to be sorted properly, whereas INDEX/MATCH does not.

Edit: Of course, after the fact, the VLOOKUP works just fine, and Eric has provided a much nicer formula.
 
Last edited:
Upvote 0
Edit: Of course, after the fact, the VLOOKUP works just fine, and Eric has provided a much nicer formula.

Yes, Eric's submission nailed it on the first shot. I appreciate your effort as well, thanks.
 
Upvote 0
Glad it works for you! :cool:

Incidentally, VLOOKUP does not require the table to be sorted, if you set the optional range_lookup parameter to FALSE, or 0.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,287
Members
452,631
Latest member
a_potato

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