Solution 1 :

Dim v
For Each htmlELE In ieObj.document.getElementsByClassName("table")(0). _

    v = htmlELE.innerText

    '  is CHR(160)
    ActiveSheet.Range("L10").Value = trim(Replace(v, "Amount:" & chr(160),""))

    'or lookfor the $ and take the rest
    p = Instr(v, "$")
    If p > 0 Then ActiveSheet.Range("L10").Value= Mid(v, p)

Problem :

This may be a pretty easy solution but I’m at a loss even though I feel close.

I’m trying to scrape market data from the TMX website, specifically I would like the dividend amount to drop into my excel workbook.

This is the below few lines of code from the “inspect” section.

<table class="table">

I need to get $0.0495 into the workbook and my vba code is the following:

For Each htmlELE In ieObj.document.getElementsByClassName("table")(0).getElementsByTagName("tr")(0).getElementsByTagName("td")
    With ActiveSheet
        .Range("L10").Value = htmlELE.Children(0).innerText
    End With

So, I’m moving through the code but the end keeps picking up “Amount:” and dropping it in the cell instead of the value, what I need, sitting on the next line.


Comment posted by 0m3r

Copy the inter html then clean it up the value

Comment posted by Matt

Thank you Tim, the second half works perfect – “looking for the $ and taking the rest.”