PDA

View Full Version : [SOLVED:] Macro to follow hyperlinks when a certain criteria is met



Swarnendu
07-21-2017, 12:50 PM
Hi,

So, I have a worksheet where the cells in Column-A (A2:A218) is hyperlinked. And, the values in Column-B (B2:B218) keep changing every 5 minutes.

I need to follow certain hyperlinks and open the webpages whenever the value in the adjacent cell (B2:B218) is <>0.

For example: During a certain time,
If B2=-4, the webpage hyperlinked in A2 opens
If B24=.01, the webpage hyperlinked in A24 opens
If B218=0, the webpage hyperlinked in A218 DOESN'T open

How can I assign a macro to do the job instead of clicking the cells myself?

Thanks,

Swarnendu

mdmackillop
07-22-2017, 03:36 AM
Sub Test()Application.OnTime Now + TimeValue("00:00:20"), "Trial"
End Sub


Sub Trial()
[b2] = Application.RandBetween(-5, -3)
If [b2] = -4 Then
Range("A2").Hyperlinks(1).Follow
'Exit Sub
End If
Test
End Sub

Swarnendu
07-22-2017, 01:16 PM
mdmackillop (http://www.vbaexpress.com/forum/member.php?87-mdmackillop) , I do have a code to follow the Hyperlink in A2 when value of B2 is <>0


Sub GoToWeb()
If [b2] <> 0 Then
Range("A2").Hyperlinks(1).Follow
End If
End Sub


What I need is a loop which will ALSO search B3,B4..B218 for values <> 0 and when found, will then follow the hyperlinks in the A column (A3,A4..A218) also.

Being a novice, I STILL don't know how to do that.:(


Swarnendu

mdmackillop
07-22-2017, 02:53 PM
It could get unmanageable by the looks of it, if too many pages are opened.

For i = 2 to 218
If Cells(i,2) <> 0 Then Cells(i,1).Hyperlinks(1).Follow
Next i

Swarnendu
07-22-2017, 03:14 PM
mdmackillop (http://www.vbaexpress.com/forum/member.php?87-mdmackillop) , no it will not open too many pages at a time.

Re the project I have already shared with you, Column B will record only the substantial difference of values between to downloads, Max 3 & Min 3, and all the other values will be converted to 0. So, In a certain period of time, maximum 6 cells in B will be <> 0 and maximum 6 webpages will open.


And, thank you for the code.

Swarnendu