• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Find text on webpage and click underlying link VBA

Shaun

Member
Hi All,

I have a list on a webpage:
Coy 1
Coy 2
Coy 3

and I want Excel to "click" on Coy 3 and load the corresponding page.

With the underlying webpage code being:
Code:
  <a href="/gdfd/Do/Something/FTRED" class="name" data-automationid="dashboard">Coy1</a>
  <a href="/gdfd/Do/Something/hdYnd" class="name" data-automationid="dashboard">Coy2</a>
  <a href="/gdfd/Do/Something/4Hte9" class="name" data-automationid="dashboard">Coy3</a>

Using:
Code:
    For Each l In IE.document.getElementsByClassName("name")
        If l.ClassName = "Coy3" Then
            l.Click
        End If
   Next
I am able to cycle through:
Code:
/gdfd/Do/Something/FTRED
/gdfd/Do/Something/hdYnd
/gdfd/Do/Something/4Hte9

but what I would like to be able to do is cycle through:
Coy 1
Coy 2
Coy 3

and when it finds Coy 3, load the webpage /gdfd/Do/Something/4Hte9

I just can't work out where I am going wrong.

Any assistance would be greatly appreciated.

Cheers
 
Back
Top