Vlookup using textbox and commandbutton

mmenofy

New Member
Joined
Apr 30, 2019
Messages
23
Hi there,

I have a sheet as follows

A B
x www.google.com
y www.yahoo.com
z www.anything.com

I created userform with (textBox1) & (commandbutton1)
i need it to : when i insert a value in textbox1 (say x or y or z), and then clicking commandbutton1 it opens the link in B column using vlookup


(I tried alot , but unfortunately it doesn't work)
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Hi. Something like this will work but you do need the full address (ie including the https:// part)

Code:
Private Sub CommandButton1_Click()

Dim fnd As Range

If UserForm1.TextBox1.Value <> "" Then
    Set fnd = Sheets("Sheet1").Range("A:A").Find(TextBox1.Value)
    If Not fnd Is Nothing Then
        If fnd.Offset(0, 1).Value <> "" Then
            ActiveWorkbook.FollowHyperlink Address:=fnd.Offset(0, 1).Value, NewWindow:=True, AddHistory:=True
            Application.WindowState = xlNormal
        End If
        Unload Me
    End If
End If

End Sub
 
Upvote 0
Sorry for disturbance steve, but the file is not working for all the column, it only returns the value of the first cell in column B, regardless the value inserted in textbox1
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,160
Members
453,021
Latest member
Justyna P

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