ahmed ramzy attia
New Member
- Joined
- Mar 18, 2018
- Messages
- 2
the below code is good but i need one for exact cell value for example pdf file 1000 in this code come to cell vaLue 1 and 10 and 100 and 1000 i need code to cell value 1000 only
Code:
Sub AddHypaerlinks()
Dim lastRow As Long
Dim myPath As String, fileName As String
myPath = "C:\Users\dchaney\Documents" 'SET TO WHERE THE FILES ARE LOCATED
lastRow = Range("A" & Rows.Count).End(xlUp).Row
For i = 2 To lastRow
fileName = myPath & Range("A" & i).Value & "*.pdf"
If Len(Dir(fileName)) <> 0 Then 'IF THE FILE EXISTS THEN
ActiveSheet.Hyperlinks.Add Range("A" & i), myPath & Dir(fileName)
End If
Next
End Sub
Code:
Sub AddHypaerlinks()
Dim lastRow As Long
Dim myPath As String, fileName As String
myPath = "C:\Users\dchaney\Documents" 'SET TO WHERE THE FILES ARE LOCATED
lastRow = Range("A" & Rows.Count).End(xlUp).Row
For i = 2 To lastRow
fileName = myPath & Range("A" & i).Value & "*.pdf"
If Len(Dir(fileName)) <> 0 Then 'IF THE FILE EXISTS THEN
ActiveSheet.Hyperlinks.Add Range("A" & i), myPath & Dir(fileName)
End If
Next
End Sub