I have a simple userform where a variable named X is set, depending on a combobox, as seen below..
it's not the whole code but just to see what is needed. When a user selects 'Order' from the combobox, variable X should be a specific website.![]()
Private Sub ComboBox1_Change() If ComboBox1 = "Order" Then X = "http://-- website address --"" End If MsgBox X End Sub
It works because a messagebox is shown with the correct website.
Now I also have a Button in the userform and when this button is pressed, it should open the website (X) in a new window, but this doesn't work...
the code for the button is:
However, the variable X is no longer filled with the website address !![]()
Sub CommandButton1_Click() ActiveWorkbook.FollowHyperlink X, NewWindow:=True End Sub
I think it's because I used the End Sub and start a new Sub but I'm not sure how to do the trick so the website opens when the button is pressed
Bookmarks