Advice for hyperlink from 2 cell values

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,226
Office Version
  1. 2007
Platform
  1. Windows
Hi,
I have the code below.
Currently if i select the value in column D "example 123456" & run the code the hyperlink works fine providing the saved file is "example 123456.pdf"

This is where i need some help.

On my worksheet in column B will be the customers name.
Example
TOM JONES 001
STEVE SMITH 003

In column D will be a 6 digit value.
Example
1D3A21
2EE2D3

The Database folder will have pdf files saved like so.
TOM JONES 001 31D5F 31-08-2023.pdf
Customers name, 6 digit code then the day the file was saved then its extension.

How would i alter the code below so when i select a 6 digit code in column D the code would take in consideration the customers name in column B & the 6 digit code in column D & then look for it in the database folder.
Example BOB BROWN 35AC12 "when the saved file is BOB BROWN 35AC1A 31-07-2023.PDF" basically a partial look up of what its saved as


Rich (BB code):
Private Sub HyperlinkDiscoKey_Click()
 Const FILE_PATH As String = "C:\Users\Ian\Desktop\REMOTES ETC\DISCO II CODE\DISCO II PDF\"
        If ActiveCell.Column = Columns("D").Column Then
          
        If Len(Dir(FILE_PATH & ActiveCell.Value & ".PDF")) Then
        ActiveCell.Hyperlinks.Add Anchor:=ActiveCell, Address:=FILE_PATH & ActiveCell.Value & ".PDF"
        MsgBox "DISCOVERY HYPERLINK SUCCESSFUL.", vbInformation, "DISCOVERY II HYPERLINK MESSAGE"
        End If
        
        Else
        MsgBox "PLEASE SELECT A CUSTOMER FIRST.", vbCritical, "DISCOVERY II HYPERLINK MESSAGE"
        Exit Sub
        End If
        
        If Dir(FILE_PATH & ActiveCell.Value & ".PDF") = "" Then
        If MsgBox("THERE IS NO FILE FOR THIS CUSTOMER" & vbNewLine & "WOULD YOU LIKE TO OPEN THE DISCO II FOLDER ?", vbYesNo + vbCritical, "DISCOVERY II HYPERLINK CUSTOMER MESSAGE.") = vbYes Then
        CreateObject("Shell.Application").Open ("C:\Users\Ian\Desktop\REMOTES ETC\DISCO II CODE\DISCO II PDF\")
        End If

    
    End If
End Sub
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December

Forum statistics

Threads
1,215,096
Messages
6,123,074
Members
449,093
Latest member
ripvw

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