Turning a customer number in a cell to an external hyperlink

Excel_Test_21

New Member
Joined
Aug 8, 2021
Messages
16
Office Version
  1. 365
Platform
  1. Windows
each morning i receive a report that has a list of customer job numbers and i am looking for a way to create a macro to have each number converted to a hyperlink that takes me to our company's customer record.

right now i have to copy the number from excel and past it in our company's look up screen to return the results.

the job # will always be in the same column and it comes up in our browser as the location ID in the script below.

for example
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Upvote 0
Thank you, i like how the code automatically changes it blue when using the =HYPERLINK
how can i get it not to be in the C column and automatically replace the number in column A
or do i have to do this in another sheet and have it pasted in to my master log sheet(the workable one)



what is the or else formula...will that script automatically change the whole column to hyper link? i see it has several lines.
 
Upvote 0
Sorry unsure what you mean this is an excel formula not VBA code, the formula can be put in any location you want i just put it in column C to show how it works.You just put the formula in column B to get
Book1
AB
11358223213582232
21358223313582233
31358223413582234
41358223513582235
51358223613582236
Sheet1
Cell Formulas
RangeFormula
B1:B5B1=HYPERLINK("https://SampleCompanyName/Office/Location/LocationInformation.aspx?locationID="&A1&"&_FK=&inCurrentCompanyStructureScope=1&hasSecurityRightToModify=1",A1)


If you just want to run some VBA to convert the numbers in column A without adding any extra columns into your hyperlink you could try
VBA Code:
Sub Hyperlink()
   For Each xCell In Range("A:A")
      If xCell.Value <> "" Then
         ActiveSheet.Hyperlinks.Add Anchor:=xCell, Address:="https://SampleCompanyName/Office/Location/LocationInformation.aspx?locationID=" & Replace(xCell.Formula, "www.", "") & "&_FK=&inCurrentCompanyStructureScope=1&hasSecurityRightToModify=1", TextToDisplay:="Website"
      End If
   Next xCell
End Sub
 
Upvote 0
Solution
Sorry unsure what you mean this is an excel formula not VBA code, the formula can be put in any location you want i just put it in column C to show how it works.You just put the formula in column B to get
Book1
AB
11358223213582232
21358223313582233
31358223413582234
41358223513582235
51358223613582236
Sheet1
Cell Formulas
RangeFormula
B1:B5B1=HYPERLINK("https://SampleCompanyName/Office/Location/LocationInformation.aspx?locationID="&A1&"&_FK=&inCurrentCompanyStructureScope=1&hasSecurityRightToModify=1",A1)


If you just want to run some VBA to convert the numbers in column A without adding any extra columns into your hyperlink you could try
VBA Code:
Sub Hyperlink()
   For Each xCell In Range("A:A")
      If xCell.Value <> "" Then
         ActiveSheet.Hyperlinks.Add Anchor:=xCell, Address:="https://SampleCompanyName/Office/Location/LocationInformation.aspx?locationID=" & Replace(xCell.Formula, "www.", "") & "&_FK=&inCurrentCompanyStructureScope=1&hasSecurityRightToModify=1", TextToDisplay:="Website"
      End If
   Next xCell
End Sub
 
Upvote 0
2023_04_05_hyperlink_code.xlsm
AB
1Service Order IDCustomer ID
21406287114062874
31406287214062875
41406287314062876
Sheet4
 
Upvote 0
how can i send you the sheet to review the code, i am not getting it to work.

if i can get it to work for column A i want to try and create a different link for column B
 
Upvote 0
Just use something like Dropbox, Mega, or any one that allows you to share a file and share the link here.
I assume when you entered the VBA you saved the file with the .xlsm extension.
Click below to download file I used
Hyperlink example
 
Upvote 0
Just use something like Dropbox, Mega, or any one that allows you to share a file and share the link here.
I assume when you entered the VBA you saved the file with the .xlsm extension.
Click below to download file I used
Hyperlink example
how can i write a code to have column b go to a different web page? i tried to keep the one for A2 and just copy the code changing the letter A to B and it did not work.

BTW i really appreciate you taking the time to help me learn this.
 
Upvote 0

Forum statistics

Threads
1,215,432
Messages
6,124,856
Members
449,194
Latest member
HellScout

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