Hi,
I need help with this. I have asked for help in other forums but I still do not have a working solution. I am a novice, so please be generous with your suggestions.
I have a file, INVLog which has invoice numbers recorded in column A in the format of "100021", "100059" etc with corresponding files in the subdirectories of a directory INVARCHIVE. I am attaching below the INVLog file I created for testing.
The INVARCHIVE directory contains subdirectories SX5021, SS4286, SS4250 and subdirectory SX5021 contaisn files 100021.xls and 100023.xls ... and so on
The following code works for me if all teh files were in the main folder and not in various subfolders within the INVARCHIVE main directoryr.
I need the code adapted so that it will do exactly what the above code does, EXCEPT that it looks in all the subfolders inside the Main INVARCHIVE folder to find teh relevant files to hyperlink to.
Both the INVLog files and the INVARCHIVE contents are added to continously, and are growing. So I would need to run teh code to hyperlink teh newly added files from time to time. Apart from hyperlinking the file names in teh INVLog to teh actual files in teh subdirectories, I do not want any otehr changes made to the files.
The final code will reside in teh INVLog file and be run from there.
Thanks for any help you can give me with this.
Talât
I need help with this. I have asked for help in other forums but I still do not have a working solution. I am a novice, so please be generous with your suggestions.
I have a file, INVLog which has invoice numbers recorded in column A in the format of "100021", "100059" etc with corresponding files in the subdirectories of a directory INVARCHIVE. I am attaching below the INVLog file I created for testing.
The INVARCHIVE directory contains subdirectories SX5021, SS4286, SS4250 and subdirectory SX5021 contaisn files 100021.xls and 100023.xls ... and so on
The following code works for me if all teh files were in the main folder and not in various subfolders within the INVARCHIVE main directoryr.
Option Explicit
Sub Hyperlink()
Dim lastRow As Long
Dim folderPath As String
Dim cell As Range
Dim i As Long
folderPath = "C:\Users\Talât\Desktop\INVARCHIVE\"
lastRow = Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 To lastRow
Range("A" & i).Select
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:=folderPath & Cells(i, 1) & ".xls"
Selection.Font.Bold = True
Selection.Font.Underline = xlUnderlineStyleNone
Selection.Font.ColorIndex = 5
Next i
MsgBox "Linking is complete."
End Sub
I need the code adapted so that it will do exactly what the above code does, EXCEPT that it looks in all the subfolders inside the Main INVARCHIVE folder to find teh relevant files to hyperlink to.
Both the INVLog files and the INVARCHIVE contents are added to continously, and are growing. So I would need to run teh code to hyperlink teh newly added files from time to time. Apart from hyperlinking the file names in teh INVLog to teh actual files in teh subdirectories, I do not want any otehr changes made to the files.
The final code will reside in teh INVLog file and be run from there.
Thanks for any help you can give me with this.
Talât