ipbr21054
Well-known Member
- Joined
- Nov 16, 2010
- Messages
- 5,832
- Office Version
- 2007
- Platform
- Windows
I have the working code in use shown below.
Currently the working code applies a hyperlink to the customers name in column B
It is at the same time i wish to add a text value for the same row in question to column C & the text is DISCO II KEY
On my form users type anything to be placed in the cell, so by making this small edit should a user type landrover the code will overwrite it to DISCO II KEY
This then helps when i look for DISCO II KEY in another form where at present iwill have missed this customer in question because the user wrote landrover
Thanks
Currently the working code applies a hyperlink to the customers name in column B
It is at the same time i wish to add a text value for the same row in question to column C & the text is DISCO II KEY
On my form users type anything to be placed in the cell, so by making this small edit should a user type landrover the code will overwrite it to DISCO II KEY
This then helps when i look for DISCO II KEY in another form where at present iwill have missed this customer in question because the user wrote landrover
Thanks
VBA Code:
Sub DISCOHYPERLINK()
Const sPath As String = "C:\Users\Ian\Desktop\REMOTES ETC\DISCO II CODE\DISCO II PDF\"
Dim sFile As String, i As Long
Dim lastrow As Long
With Sheets("POSTAGE")
lastrow = .Range("B" & .Rows.Count).End(xlUp).Row
For i = lastrow - 10 To lastrow
sFile = sPath & .Range("B" & i).Value & ".pdf"
If Len(Dir(sFile)) Then
.Range("B" & i).Hyperlinks.Add Anchor:=.Range("B" & i), Address:=sFile
End If
Next
End With
MsgBox "CUSTOMER WAS HYPERLINKED.", vbInformation, "DISCO II HYPERLINK MESSAGE"
'NOW SAVE & CLOSE DISCO CALC WORKBOOK
Workbooks("DISCO CALC.xlsm").Close SaveChanges:=True
End Sub