Quoting a value in a html table

henryvii99

New Member
Joined
Apr 22, 2011
Messages
32
Hello everyone,

I had a UDF which can quote the real time prices from aastock, which basically found the span class "pos bold","neg bold" or "unc bold" in the html (May thanks to pbornemeier!)

The code is:

Code:
 Dim aryTypes As Variant
    
    aryTypes = Array("pos bold", "neg bold", "unc bold")
 
    On Error GoTo er
    Set xlhttp = CreateObject("Msxml2.XMLHTTP")
    With xlhttp
        .Open "get", "http://www.aastocks.com/sc/ltp/rtquote.aspx?symbol=" & dm & "&time=" & Timer, False
        .send
 
        sOutput = StrConv(.responsebody, vbUnicode)
        For lx = LBound(aryTypes) To UBound(aryTypes)
            lPosition = InStr(sOutput, aryTypes(lx))
            If lPosition > 0 Then 'search value was found
                sExtract = Mid(sOutput, lPosition, 100) 'get enough of a string to include the % if it exists
                'Debug.Print aryTypes(lx), Trim(sExtract)
                If InStr(sExtract, "%") > 0 Then
                    'Don't want
                Else
                    sType = aryTypes(lx)
                    Exit For
                End If
            End If
        Next
        
        sExtract = Mid(sExtract, InStr(sExtract, ">") + 1, 100)
        StockVal = Left(sExtract, InStr(sExtract, "<") - 1)
        'Debug.Print dm, sType, StockVal
        
    End With
    Set xlhttp = Nothing
    Exit Function
er:
    StockVal = "err"
End Function

Now I want to quote the volume, which is the first div class named "floatR p2" in the elements. This class will not give any weird outputs (sometimes the price gives a percentage) as in above, so I tried to modify the codes, but it doesn't work.

Many thanks in advance!!
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
I think it can be done by deleting a few code, but it seems that I got them wrong. Can anyone help me please? :biggrin:
 
Upvote 0

Forum statistics

Threads
1,224,598
Messages
6,179,820
Members
452,946
Latest member
JoseDavid

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