Inserting a hyperlink via a condition

jaypatel

Active Member
Joined
Nov 25, 2002
Messages
389
Hi,

How would you write a macro that would insert a hyperlink in column L via a condition where:

- any cells in column h(x) is >1000

and where the the actual link is ""columnJ(x)"" where the text in column J is blue (a hyperlink)....

an example

cell h2 = 1003, cell j2= text then in cell L2 insert hyperlink called "text.xls"
cell h3 = 993, cell j3 = text1 then insert no hyperlink.

Jay
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Try:

Code:
Sub xxx()
Dim ce As Range
For Each ce In Range("H:H")
If ce.Value > 1000 Then ActiveSheet.Hyperlinks.Add Anchor:=Cells(ce.Row, 12), Address:=Cells(ce.Row, 10)
Next ce
End Sub
 
Upvote 0
Hi this works a treat..... but realised one problem....

i also want the hyperlink to be true where column J is only a numerical field and not a text field.

Cheers

Jay
 
Upvote 0
yes......

for example,
if j2="alpha" and h=1400 then do not create hyperlink

or if j3="145" (ie a number) and h=1401 then create a hyperlink.

ie still have the condition where h column must also be greater than 1000 as well.

Jay
 
Upvote 0
Code:
Sub xxx()
Dim ce As Range
For Each ce In Range("H:H")
If ce.Value > 1000 Then If WorksheetFunction.IsNumber(Cells(ce.Row, 10)) Then ActiveSheet.Hyperlinks.Add Anchor:=Cells(ce.Row, 12), Address:=Cells(ce.Row, 10)
Next ce
End Sub

But I still don't get why you want number as link.
 
Upvote 0

Forum statistics

Threads
1,214,911
Messages
6,122,198
Members
449,072
Latest member
DW Draft

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