title: How to click an href within HTML table if cell value within same row equals value in Excel workbook
body: <p>I'm attempting to automate the population of a webform based on values in an excel template.  I've successfully been able to access the site and navigate through a few clicks with the VBA code below.  Next, I need to tackle an HTML table.  I'm needing to click the href containing inner text "reconcile" if a cell in the same row of the HTML table equals a value keyed into my Excel workbook.  The HTML table contains many rows, I've truncated the HTML code below to just include 2 rows for illustration (bullets 2 and 3).  Using row "bullet 2" for example, I'm need to click the href within that row if a cell in my workbook equals "2205021" ("2205021" is a uniquely identifiable cell value in both the HTML table and my Excel workbook).</p>
  
  <p>Please note that I'm not wanting to reference any uniquely identifiable attributes of the href such as "id" because I'm needing the code to be written generally to apply to all of my Excel templates, relying only on the uniquely identifiable cell value eluded to above (unless there's a way to do this that still achieves my desired result).</p>
  
  <p>Any help would be greatly appreciated,</p>
  
  <p>Grant</p>
  
  <p>My VBA code thus far:</p>
  
  <pre><code>Sub ieBusy(ie As Object)
      Do While ie.Busy Or ie.ReadyState &lt; 4
      DoEvents
  Loop
  End Sub
  
  Sub FillInternetForm()
  Dim ie As Object
  Set ie = CreateObject("InternetExplorer.Application")
  
  ie.Navigate "https://Website I'm Navigating To"
  ie.Visible = True
  
  ieBusy ie
  
  Set AllHyperLinks = ie.Document.getElementsByTagName("A")
  For Each Hyper_link In AllHyperLinks
      If Hyper_link.innerText = "Reconciliations" Then
          Hyper_link.Click
          Exit For
      End If
  Next
  
  ieBusy ie
  
  Dim mySelection As String, mySelObj As Object
  Set mySelObj = ie.Document.getElementById("ctl00_MainContent_ucDashboardPreparer_ucDashboardSettings_ctl00_ddlRoles")
  
  mySelection = ThisWorkbook.Sheets("1").Range("b2").Value    
  Select Case mySelection
  Case "Preparer", "Reviewer", "Approver"
  Case Else
      MsgBox "Invalid Selection!"
      ie.Quit
      Exit Sub
  End Select
  
  mySelObj.Value = mySelection
  
  ieBusy ie
  
  Set mySelObj = ie.Document.getElementById("ctl00_MainContent_ucDashboardPreparer_ucDashboardSettings_ctl00_ddlEffectiveDate")
  
  mySelection = ThisWorkbook.Sheets("1").Range("c8").Value    
  Select Case mySelection
  Case "12/31/2017" 'I'll ref a cell in my workbook here once code is built out
  Case Else
      MsgBox "Invalid Selection!"
      ie.Quit
      Exit Sub
  End Select
  </code></pre>
  
  <hr>
  
  <p>Relevant HTML Code:</p>
  
  <pre class="lang-htm prettyprint-override"><code>1."&lt;table class=""rgMasterTable"" 
  id=""ctl00_MainContent_assignedAccountsGrid_ctl00"" style=""border-width: 
  0px; width: 100%; table-layout: auto; empty-cells: show;"" border=""0"" 
  cellspacing=""1"" cellpadding=""2""&gt;"
  
    &lt;tbody&gt;
  2. &lt;tr class="rgRow" id="ctl00_MainContent_assignedAccountsGrid_ctl00__0" style="white-space: nowrap;" onclick="javascript:needToConfirm = false;"&gt;
      &lt;td style="display: none;"&gt;29937&lt;/td&gt;&lt;td style="display: none;"&gt;0&lt;/td&gt;&lt;td style="display: none;"&gt;3199&lt;/td&gt;&lt;td style="display: none;"&gt;&amp;nbsp;&lt;/td&gt;&lt;td style="display: none;"&gt;False&lt;/td&gt;&lt;td style="display: none;"&gt;False&lt;/td&gt;&lt;td&gt;
                              &lt;img title="Not Started" id="ctl00_MainContent_assignedAccountsGrid_ctl00_ctl04_StatusIcon" style="border-width: 0px;" alt="Not Started" src="../images/document_plain_new.gif"&gt;
                          &lt;/td&gt;&lt;td&gt;
                              &lt;a tabindex="33" id="ctl00_MainContent_assignedAccountsGrid_ctl00_ctl04_lnkReconcile" onclick="javascript:return CheckInterval();" href="javascript:__doPostBack('ctl00$MainContent$assignedAccountsGrid$ctl00$ctl04$lnkReconcile','')"&gt;Reconcile&lt;/a&gt;
                          &lt;/td&gt;&lt;td&gt;US&lt;/td&gt;&lt;td&gt;CORP&lt;/td&gt;&lt;td&gt;DOM&lt;/td&gt;&lt;td&gt;2205021&lt;/td&gt;&lt;td&gt;XX&lt;/td&gt;&lt;td&gt;XX&lt;/td&gt;&lt;td&gt;XX&lt;/td&gt;&lt;td&gt;0L&lt;/td&gt;&lt;td&gt;Group Insurance Withholding&lt;/td&gt;&lt;td align="center"&gt;12/31/2017&lt;/td&gt;&lt;td align="center" class="Delinquent"&gt;1/28/2018&lt;/td&gt;&lt;td align="right"&gt;10,920.72&lt;/td&gt;&lt;td align="right"&gt;0.00&lt;/td&gt;&lt;td&gt;
  
                          &lt;/td&gt;&lt;td align="right"&gt;&amp;nbsp;&lt;/td&gt;&lt;td align="right"&gt;10,920.72&lt;/td&gt;&lt;td&gt;Grant Bangerter&lt;/td&gt;&lt;td&gt;Ryan Smith&lt;/td&gt;&lt;td&gt;
                              &lt;span id="ctl00_MainContent_assignedAccountsGrid_ctl00_ctl04_lblResponsibilty"&gt;Primary&lt;/span&gt;
                          &lt;/td&gt;&lt;td style="display: none;"&gt;False&lt;/td&gt;
  3. &lt;/tr&gt;&lt;tr class="rgAltRow" id="ctl00_MainContent_assignedAccountsGrid_ctl00__1" style="white-space: nowrap;" onclick="javascript:needToConfirm = false;"&gt;
      &lt;td style="display: none;"&gt;28148&lt;/td&gt;&lt;td style="display: none;"&gt;0&lt;/td&gt;&lt;td style="display: none;"&gt;3199&lt;/td&gt;&lt;td style="display: none;"&gt;&amp;nbsp;&lt;/td&gt;&lt;td style="display: none;"&gt;False&lt;/td&gt;&lt;td style="display: none;"&gt;False&lt;/td&gt;&lt;td&gt;
                              &lt;img title="Not Started" id="ctl00_MainContent_assignedAccountsGrid_ctl00_ctl06_StatusIcon" style="border-width: 0px;" alt="Not Started" src="../images/document_plain_new.gif"&gt;
                          &lt;/td&gt;&lt;td&gt;
                              &lt;a tabindex="33" id="ctl00_MainContent_assignedAccountsGrid_ctl00_ctl06_lnkReconcile" onclick="javascript:return CheckInterval();" href="javascript:__doPostBack('ctl00$MainContent$assignedAccountsGrid$ctl00$ctl06$lnkReconcile','')"&gt;Reconcile&lt;/a&gt;
                          &lt;/td&gt;&lt;td&gt;US&lt;/td&gt;&lt;td&gt;CORP&lt;/td&gt;&lt;td&gt;DOM&lt;/td&gt;&lt;td&gt;GRP.2203015&lt;/td&gt;&lt;td&gt;XX&lt;/td&gt;&lt;td&gt;XX&lt;/td&gt;&lt;td&gt;XX&lt;/td&gt;&lt;td&gt;0L&lt;/td&gt;&lt;td&gt;Accrued Dental Insurance Expense&lt;/td&gt;&lt;td align="center"&gt;12/31/2017&lt;/td&gt;&lt;td align="center" class="Delinquent"&gt;1/28/2018&lt;/td&gt;&lt;td align="right"&gt;-12,751,041.02&lt;/td&gt;&lt;td align="right"&gt;0.00&lt;/td&gt;&lt;td&gt;
  
                          &lt;/td&gt;&lt;td align="right"&gt;&amp;nbsp;&lt;/td&gt;&lt;td align="right"&gt;-12,751,041.02&lt;/td&gt;&lt;td&gt;Grant Bangerter&lt;/td&gt;&lt;td&gt;Ryan Smith&lt;/td&gt;&lt;td&gt;
                              &lt;span id="ctl00_MainContent_assignedAccountsGrid_ctl00_ctl06_lblResponsibilty"&gt;Primary&lt;/span&gt;
                          &lt;/td&gt;&lt;td style="display: none;"&gt;False&lt;/td&gt;
  </code></pre>
  
  <p>I can provide further HTML code from webform if needed.</p>