# Hyperlink condition for a cell

#### Karti

##### New Member
Hi all,

Hope some one can advise me on this. I have a worksheet with a cell that will have a possible list of numbers 1,2,3 and 4 etc.

This would be Cell A1

Dependant on the number in the cell, I would like the hyperlink to point to a different area/site

I am assuming that it would have to be done in VBA but not really used it much

I see it as:

If A1 = 1 then goto "http://www.google.co.uk"
or
If A1 = 2 then goto "http://www.yahoo.co.uk"
or
If A1 = 3 then goto "Cell AA2"

If anyone could give me some advice this would be greatly appreciated.

Regards

K

### Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Create a list on another worksheet with your information where column A is your list of numbers, and Column B is your list of websites that correspond to your numbers in A.

Then on a new worksheet in cell B1 put in a formula to do a VLOOKUP(A1,Your Data range on other Worksheet,2, false).

This will then give you a link to click on to go to whereever.

Last edited:
DreamAlchemist,

Many thanks for your prompt response. After trying this it gives me the correct link but not as a hyperlink and not in the actual number cell, but rather in the one to its left.

Is there a way using VLOOKUP that I could do both of the above as well?

Many thanks

K

Hi I have played about and can get this to work:

Code:
``````Private Sub CommandButton1_Click()

Application.Run "Book2.xlsm!Sheet3.Macro32"

End Sub

Sub Macro32()
'
' Macro1 Macro

If Range("D5") = 1 Then
Range("D5").Select
End If

If Range("D5") = 2 Then
Range("D5").Select
End If

If Range("D5") = 3 Then
Range("D5").Select
End If

End Sub``````

If someone could perhaps advise on a way to tidy the code up that would be great.

Regards

K

Replies
0
Views
267
Replies
7
Views
757
Replies
8
Views
738
Replies
1
Views
205
Replies
0
Views
286

1,203,485
Messages
6,055,691
Members
444,807
Latest member
RustyExcel

### 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.

### Which adblocker are you using?

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

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