Auto Hyperlinking

Takron

New Member
Joined
May 12, 2011
Messages
12
Is there some way to make text in a cell auto hyperlink to a search engine when you type it in? Instead of manually linking each text to the site?
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Not totaly sure what you mean.

If you have the 'base' URL for the search and the search term(s) then you should be able to concatenate them to get the required URL for the search.

Then you can use the HYPERLINK worksheet function to turn that into a hyperlink.

PS Excel might turn it into a hyperlink anyway, but just to be sure that you get the right hyperlink probably best to use HYPERLINK.
 
Upvote 0
Let's say that I type Splicing into the cell. I want to be able to set it up so the cell auto links the Splicing word so when you click on it, it takes you to the search engine and searches for Splicing.
 
Upvote 0
So where does the URL for the search come from?
 
Upvote 0
It comes up as a hyperlink but since its generated with the function, it won't let you click it. It just highlights the box for editing.
 
Upvote 0
Let's say that I type Splicing into the cell. I want to be able to set it up so the cell auto links the Splicing word so when you click on it, it takes you to the search engine and searches for Splicing.

Right click the worksheet tab and choode View code from the popup menu and place the following code in the white pane sheet module :

Code:
Private Sub Worksheet_Change(ByVal Target As Range)

    On Error GoTo ErrHandler
    
    If Target.Address = Range("A1").Address Then
        ThisWorkbook.FollowHyperlink _
        "http://www.google.com/search?q=" & Target
    End If
    
ErrHandler:
    MsgBox Err.Description
        
End Sub
This will work for cell A1. change the entry cell address as needed.
 
Last edited:
Upvote 0
Or maybe this to add the hyperlink to the entry cell but not to follow the link until the user clicks on it

Code:
Private oTarget As Range

Private Sub Worksheet_Change(ByVal Target As Range)
    
    If Target.Address = Range("A1").Address Then
        If Not IsEmpty(Target) Then
            Set oTarget = Target
            Application.OnTime Now + TimeSerial(0, 0, 1), _
            Me.CodeName & ".AddHyperlink"
        End If
    End If
        
End Sub


Private Sub AddHyperlink()

    On Error GoTo ErrHandler
    
    With oTarget
        Hyperlinks.Add Anchor:=oTarget, Address:= _
        "http://www.google.com/search?q=" & .Text, _
        TextToDisplay:=.Text
    End With
    
    Set oTarget = Nothing
    Exit Sub
    
ErrHandler:
   
    MsgBox Err.Description

End Sub
 
Upvote 0

Forum statistics

Threads
1,224,618
Messages
6,179,919
Members
452,949
Latest member
beartooth91

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top