• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Auto Hyperlink Trouble.

qwer123

New Member
In my Excel worksheet, I would like to create a formula where If cell contains the text "Done" that automatically triggers a pop-up window to hyperlink desired file by selecting it from the local drive. Badly need it. Please help me out by making it in excel sheet and send me copy of it please. :(
 
Excel formulas alone can’t directly trigger pop-up windows or file dialogs—but VBA can easily make that magic happen!

Paste the following into the sheet level module :

Code:
Private Sub Worksheet_Change(ByVal Target As Range)

    Dim cell As Range

    Dim selectedFile As Variant



    ' Adjust to your target range, e.g., column A

    If Not Intersect(Target, Me.Range("A:A")) Is Nothing Then

        Application.EnableEvents = False



        For Each cell In Intersect(Target, Me.Range("A:A"))

            If LCase(cell.Value) = "done" Then

                ' Open file picker

                selectedFile = Application.GetOpenFilename("All Files (*.*), *.*", , "Select File to Link")



                ' If a file was selected

                If selectedFile <> False Then

                    ' Add hyperlink to the same cell

                    Me.Hyperlinks.Add _

                        Anchor:=cell, _

                        Address:=selectedFile, _

                        TextToDisplay:="Linked File"

                End If

            End If

        Next cell



        Application.EnableEvents = True

    End If

End Sub

Anytime "Done" is entered into Col A, The file window will open.
 
Back
Top