Create a hyperlink automatically based on cell value

paun_shotts

New Member
Joined
Nov 4, 2021
Messages
41
Office Version
  1. 2013
Platform
  1. Windows
I have a spreadsheet where in column H the user is required to put in a con-note tracking number for a return parcel.
I was wondering if there is a way, either with a macro or a formula to convert this connote into a hyperlink.
The con-note is created with Startrack most of the time.
The con-note number is 12 characters long
The con-note always starts with "8KSZ"

I would like a solution that checks the data in column H, if the data there is 12 character long and starts with 8KSZ
Then
Convert that cell to a hyperlink pointing to the following location:
https : // auspost.com.au/mypost/track/#/details/"DATA IN CELL IN COLUMN H"
Without the spaces after https

If the data in column H is not 12 characters long and does not start with 8KSZ then leave the data in that cell as it is (no hyperlink)

QAD0702 GRA Log Records (Since May 2009) (Rev 4, 12-08-2022).xlsx
ABCDEFGH
1GRA#GRA Raised DateProcedure/Case DateInitialCustomer / SupplierCAR/Repair # [if applicable]Details (Product#, Serial#, Lot#, etc.) please include: quantities, brand name, etc.Con Note #
222010014/01/2022CBGold Coast Univ Hospital1 x 94202 return for credit8KSZ00014786
322010024/01/2022CBWollongong Public Hospital1 x 60013878KSZ00014794
422010034/01/2022LFSir Charles Gairdner Return of loan stock 8KSZ00014809
522010044/01/2022LFSir Charles Gairdner Return of loan stock 8KSZ00014810
2022
Cells with Conditional Formatting
CellConditionCell FormatStop If True
C1Expression=$J1="Yes"textNO
C2:C47,C49:C64,C66:C1048576Expression=$J2="Yes"textNO
B1Expression=$J1="Yes"textNO
K1:Q2,A2:B47,K76:L114,L115:L127,L128:Q129,K130:Q413,K415:Q430,K414,M414:Q414,K432:Q450,K431,M431:Q431,K455,M455:Q455,K462:K465,M462:Q465,K456:Q456,K452:Q454,K451,M451:Q451,K469:K470,K458:Q461,K457,M457:Q457,K3:L60,A49:B64,K62:L74,N3:Q127,A1,K466:Q468Expression=$J1="Yes"textNO
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Put this in the worksheet's sheet module:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

    If Target.Count = 1 And Target.Column = 8 And Target.Row >= 2 Then
        If Left(Target.Value, 4) = "8KSZ" And Len(Target.Value) = 12 Then
            Target.Hyperlinks.Add Target, "https://auspost.com.au/mypost/track/#/details/" & Target.Value, , , Target.Value
        End If
    End If
  
End Sub
 
Upvote 0
Solution
Put this in the worksheet's sheet module:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

    If Target.Count = 1 And Target.Column = 8 And Target.Row >= 2 Then
        If Left(Target.Value, 4) = "8KSZ" And Len(Target.Value) = 12 Then
            Target.Hyperlinks.Add Target, "https://auspost.com.au/mypost/track/#/details/" & Target.Value, , , Target.Value
        End If
    End If
 
End Sub
Thank you very much sir!
 
Upvote 0

Forum statistics

Threads
1,223,912
Messages
6,175,348
Members
452,638
Latest member
Oluwabukunmi

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