Hyperlink Method

     

  • It enables the user to redirect to other link as mentioned in code
  •  

    Code:

     

    Private Sub CommandButton1_Click()
    Mention the web link in the code ActiveWorkbook.FollowHyperlink Address:="http://www.Tricks12345.com", _
    NewWindow:=True
    End Sub

     

     

    Hyperlink Method - Based on Caption

     

  • Insert Command Button on Excel sheet
  • Enter the code
  • Execute the code
  •  

    Code:

    Private Sub CommandButton1_Click()
    CommandButton1.Caption = "http://www.Tricks12345.com"
    'first parent = parent to command button 1 = worksheet
    'second parent = parent to worksheet = workbook
    CommandButton1.Parent.Parent.FollowHyperlink CommandButton1.Caption
    End Sub