Hyperlink Customization in excel

2

Does anyone know if there is any way I can create a hyperlink in a cell in excel where the value specified in this cell is passed to the id value of a URL? Example:

Cell with value: 100531, when clicking on it, call a url link where VALORDACELULA is the value that is in the cell that was clicked?

Thank you in advance.

    
asked by anonymous 22.08.2016 / 23:16

1 answer

2

Do the following:

  • In the cell where the value is, right-click and select "Hyperlink."

  • In the hyperlinks window, select the "Place In This Document" button and enter the address of the cell itself where the value is. Click OK. This hyperlink will not do anything as it takes you to the cell where it was clicked.

  • Open the Excel VBA code window ( ALT + F11 ) and add the following code to the worksheet:
  • Private Sub Worksheet_FollowHyperlink(ByVal oTarget As Hyperlink)
        Dim sURL As String
        sURL = "http://teste/teste/view.php?id=" & ActiveCell.Value
        ActiveWorkbook.FollowHyperlink sURL
    End Sub
    
      

    Note that this code captures the event of the specific worksheet (the    worksheet , that is, the tab) and not the whole file. If you have more than one   (Plan1, Plan2, Plan3, etc.) and you want to do the same on it, you need to double   this code.

        
    22.08.2016 / 23:41