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
 
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
i just realized, our customer numbers will have multiple jobs following for example 12345678-01, 12345678-02. i would need the hyperlink to drop the -01 & -02 to access the company weblink.
let me know your thoughts so i don't have to have an extra column if possible
 
Upvote 0

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Doyou mean the Servive order will have extra on the job number like below, can you give example please as do you want "-01" removed from a specific column or all columns

hyperlinks3.xlsm
AB
1Service order IDCustomerID
2123111111
3456222222
4789333333
511112444444
6131415555555
7456789666666
86785777777
9758764888888
1011112-01444444
11131415-02555555
12456789-11666666
13123-13111111
14456-05222222
Sheet1
 
Upvote 0
Hyperlink 2 column change
See file example attached updated code to remove the numeric extensions in column A and allow hyperlinks to be added to column 2.
One of the more proficent VBA guys may be able to offer a neater code but this works for me.

VBA Code:
Sub createLink()

    Dim Rng As Range
    Dim x, y As Integer
    Dim LastRowA, LastRowB As Integer
    LastRowA = Cells(Rows.Count, "A").End(xlUp).Row
    LastRowB = Cells(Rows.Count, "B").End(xlUp).Row
    Set Rng = Range("A2", Range("A2").End(xlDown)) 'This is column with hyphen extensions
    Rng.Replace What:="-*", Replacement:="", LookAt:=xlPart 'Anything with a - , replace it and all after it with nothing
    
    With ActiveWorkbook.Worksheets("Sheet1")
        For x = 2 To LastRowA
        Cells(x, "A").Activate
        .Hyperlinks.Add Anchor:=ActiveCell, Address:="https://SampleCompanyName/Office/Location/LocationInformation.aspx?locationID=" _
        & ActiveCell.Text & "&_FK=&inCurrentCompanyStructureScope=1&hasSecurityRightToModify=1", TextToDisplay:=ActiveCell.Text
        Next x
        
        For y = 2 To LastRowB
        Cells(y, "B").Activate
        .Hyperlinks.Add Anchor:=ActiveCell, Address:="https://SampleColB_name" & ActiveCell.Text & "extra_if_needed", TextToDisplay:=ActiveCell.Text
        Next y
    End With
  End Sub
 
Upvote 0

Forum statistics

Threads
1,223,247
Messages
6,171,007
Members
452,374
Latest member
keccles

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