'Inserting hyperlink to folder created with VBA EXCEL
The below code is to create a new folder and name it on the list of names on Column "A", and if it doesn't have "OK" on Column "H" it will not create that folder. Now, I am trying to make it so that it would create a "DONE" message in Column "I" that is hyperlinked to the folder created.
Sub NewFolder()
Dim R_EmptyLines, R_Line As Integer
R_EmptyLines = 0
R_Line = 2
Dim fso As Object
Dim fldrname As String
Dim fldrpath As String
Dim EIposition As String
Dim Remark_note As String
While R_EmptyLines < 10
Set fso = CreateObject("scripting.filesystemobject")
fldrname = UCase(Trim(Range("A" & Trim(Str(R_Line)))))
fldrpath = "C:\TEST\FOLDER\" & fldrname
EIposition = Range("H" & Trim(Str(R_Line)))
If Len(fldrname) < 7 Then
R_EmptyLines = R_EmptyLines + 1
Else
R_EmptyLines = 0
If EIposition = "OK" Then
If Not fso.FolderExists(fldrpath) Then
fso.createfolder (fldrpath)
'- - - - - - - - - - - - - - - - - - - - - - - -
Range("I" & Trim(Str(R_Line))) = ActiveSheet.Hyperlinks.Add , Address:= _
fldrpath, TextToDisplay:="DONE"
'- - - - - - - - - - - - - - - - - - - - - - - -
End If
End If
End If
R_Line = R_Line + 1
Wend
Exit Sub
End Sub
Solution 1:[1]
Finally manage to make it work. I just placed the Range wrongly
If Not fso.FolderExists(fldrpath) Then
fso.createfolder (fldrpath)
ActiveSheet.Hyperlinks.Add Range("I" & Trim(Str(R_Line))), Address:=fldrpath, TextToDisplay:="DONE"
End If
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Ebel Ere |
