BalloutMoe
Board Regular
- Joined
- Jun 4, 2021
- Messages
- 137
- Office Version
- 365
- Platform
- Windows
Hello All I am trying to get some data from a table on a website. I need some help the following is a sample of each transaction inside the table after being located by driver.FindElementById("account_history").
What I need is if the class="active_column date_c" . text is equal to a certain date for example "04/04/2022" To copy into the sheet
class="active_column date_c"
class="itemtype_c"
class="description_c"
class="red_color amount1_c" here however if the class is class="green_color amount1_c" then I would like to make the value into a negative number before placing it into the worksheet. I have the below code but I am stuck on how to proceed. This code prints all the information from the table into the worksheet with no adjustments at all.
My code:
Thank you
What I need is if the class="active_column date_c" . text is equal to a certain date for example "04/04/2022" To copy into the sheet
class="active_column date_c"
class="itemtype_c"
class="description_c"
class="red_color amount1_c" here however if the class is class="green_color amount1_c" then I would like to make the value into a negative number before placing it into the worksheet. I have the below code but I am stuck on how to proceed. This code prints all the information from the table into the worksheet with no adjustments at all.
Rich (BB code):
<tr id="transaction_2_126006020003330" clickeventnotsetted="1" style="" postingdate="04/04/2022" pagen="2" check_number="0" transactionid="2_126006020003330" transaction_row="" class="transaction_row bottom_border padding_top_bottom_8 transaction_row odd" role="row">
<td align="center" class="active_column date_c" style="position:relative"> 04/04/2022</td>
<td class="itemtype_c">ACH Withdrawal</td>
<td align="left" width="40%" class="description_c">WASTE CONNECTION-WEB_PAY</td>
<td class="red_color amount1_c">$ 135.77</td>
<td align="right" class="hide-on-sort">$ 451.86</td>
<td class="end-icon"><img src="images/trans-ok.png"></td>
<img src="images/trans-ok.png">
</td>
</tr>
<tr id="transaction_2_126006020003331" clickeventnotsetted="1" style="" postingdate="04/04/2022" pagen="2" check_number="0" transactionid="2_126006020003331" transaction_row="" class="transaction_row bottom_border padding_top_bottom_8 transaction_row even" role="row">
<td align="center" class="active_column date_c" style="position:relative"> 04/04/2022</td>
<td class="itemtype_c">ACH DEPOSIT</td>
<td align="left" width="40%" class="description_c">AUTOZONE RETURN</td>
<td class="green_color amount1_c" align="right">$ 9.59</td>
<td align="right" class="hide-on-sort">$ 451.86</td>
<td class="end-icon"><img src="images/trans-ok.png"></td>
<img src="images/trans-ok.png">
</td>
</tr>
My code:
VBA Code:
Sub GetInformation()
Dim driver As New WebDriver
Dim TransTable As Selenium.WebElement
Dim AllRows As Selenium.WebElements
Dim SingleRow As Selenium.WebElement
Dim AllRowCells As Selenium.WebElements
Dim SingleCell As Selenium.WebElement
Dim objFSO As Scripting.FileSystemObject
Set objFSO = CreateObject("Scripting.FileSystemObject")
driver.Start "chrome", ""
driver.Get
MsgBox "Login now and click OK when done."
driver.FindElementById("DataTables_Table_0_length").FindElementsByTag("option")(3).Click
Set TransTable = driver.FindElementById("account_history")
Set AllRows = TransTable.FindElementsByTag("tr")
For Each SingleRow In AllRows
Set AllRowCells = SingleRow.FindElementsByTag("td")
RowNum = RowNum + 1
For Each SingleCell In AllRowCells
ColNum = ColNum + 1
Set TargetCell = ThisWorkbook.Worksheets(2).Cells(RowNum, ColNum)
TargetCell.Value = SingleCell.Text
Next SingleCell
ColNum = 0
Next SingleRow
driver.FindElementById("dropdown5").Click
End Sub
Thank you