VBA and Excel: navigate web, looping in a table and click the relevant row

Nelson78

Well-known Member
Joined
Sep 11, 2017
Messages
526
Office Version
  1. 2007
Hello everybody.

I'm surfing a web site and grasping data.

Now, I'm tinkering with a table.

Its name is:

HTML:
id="tbl1"

The body is structured as follows:

HTML:
<tbody>
	<tr class="Row" id="tbl1__0">
		<td align="center">A1</td><td>xxxx</td><td>66</td><td>0</td>
	</tr><tr class="AltRow" id="tbl1__1">
		<td align="center">A3</td><td>yyyy</td><td>4</td><td>0</td>
	</tr><tr class="Row" id="tbl1__2">
		<td align="center">A4</td><td>zzzz</td><td>151</td><td>0</td>
	</tr><tr class="AltRow" id="tbl1__3">
		<td align="center">A7</td><td>wwww</td><td>1</td><td>0</td>
	</tr><tr class="Row" id="tbl1__4">
		<td align="center">A8</td><td>nnnn</td><td>395</td><td>0</td>
	</tr><tr class="AltRow" id="tbl1__5">
		<td align="center">A9</td><td>rrrr</td><td>1</td><td>0</td>
	</tr><tr class="Row" id="tbl1__6">
		<td align="center">A10</td><td>ssss</td><td>239</td><td>0</td>
	</tr><tr class="AltRow" id="tbl1__7">
		<td align="center">A13</td><td>dddd</td><td>67</td><td>0</td>
	</tr>
	</tbody>

The table can have an indefinite number of rows.
I need to click In the row containing the code "A3", "A4" or "A27", to download the corresponding records.

How can I loop in this table and perform the task?

Thank's in advance for your support.
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
No way, until now.

Code:
Dim elements As Object
    Set elements = HTMLdoc.getElementById("tbl1")
Dim ele As Object
    
    For Each ele In elements     
        If ele = "A3" Or "A4" Or "A27" Then
            ele.Click
            Exit For
        End If
    Next ele

Error 438"Object Doesn't Support This Property or Method"

in line

Code:
For Each ele In elements
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,815
Messages
6,121,715
Members
449,049
Latest member
THMarana

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