Userform Textbox Contents Output to Formula

Bench

Board Regular
Joined
Aug 27, 2009
Messages
134
I'll try and make this as clear as possible, please feel free to check for clarity though.

Basically i'm building a tool that will allow users to establish the distance between two postal codes.

It works on a very simple basis, simply entering the two postcodes into a hyperlink at the appropriate place. Because of the format of the link, lots of / /'s etc i've had to split it up.

and then add it together:

leaving me with something like this:

=HYPERLINK(B2&B3&B4&B5&B6,"Get Directions")

What i would like to do i use a InputBox (though i guess a textbox inside a userform is going to be the solution) with Two Fields, Start PostCode & End Postcode, upon clicking "Ok" the hyperlink will be created and ideally followed.

In a nutshell i suppose what i need to know is how to extract the answers from an input field and add them to a generic text to form a hyperlink.

Any ideas? Is this possible?

Thanks

Ben
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Managed to work it out:

Code:
Private Sub GetDirections_Click()
        Dim NextRow As Long
'   Make sure Sheet1 is active
    Sheets("Sheet3").Activate
'   Make sure a name is entered
    If TextBox1.Text = "" Then
        MsgBox "You must enter a name."
        Exit Sub
    End If
    
'   Transfer the name
    Range("L1").Select
    ActiveCell = TextBox1.Text

    If TextBox1.Text = "" Then
        MsgBox "You must enter a name."
        Exit Sub
    End If
    Range("N1").Select
    ActiveCell = TextBox2.Text
       
    ThisWorkbook.FollowHyperlink Address:=Range("P1")
    Range("A1").Select
    Unload Me
    Unload SearchBox
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,847
Messages
6,121,911
Members
449,054
Latest member
luca142

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