Consulting

Results 1 to 5 of 5

Thread: Macro to follow hyperlinks when a certain criteria is met

  1. #1

    Macro to follow hyperlinks when a certain criteria is met

    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

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    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
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

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

  4. #4
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    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
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  5. #5
    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
    Last edited by Swarnendu; 07-22-2017 at 05:49 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •