Get Number from website

Av8tordude

Well-known Member
Joined
Oct 13, 2007
Messages
1,075
Office Version
  1. 2019
Platform
  1. Windows
On Yahoo finance, the line in the HTML code below is the number (13.00) and I would to display a msgbox with the results . I manage to put together some code watching youtube videos, however i can not get the number to display in a msgbox. Then msgbox should say 13.00. Can you assist.

Many thanks

Range("A1") = DIS181123C00102000

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim IE As New InternetExplorer


IE.Visible = True
IE.navigate "https://finance.yahoo.com/quote/" & Range("A1") & "?p=" & Range("A1")
Do
    DoEvents
Loop Until IE.readyState = READYSTATE_COMPLETE
Dim Doc As HTMLDocument
Set Doc = IE.document
Dim sDD As String
sDD = Doc.getElementsByClassName("D(ib)")(1).innerText


MsgBox sDD 


End Sub
 
Last edited:
Works like a Gem. Thank you. One question....When I run the code the first time, its executes slow, however each time thereafter it executes fairly fast. Any explanation? I'm just curious. Thanks again for your help!
 
Upvote 0

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Works like a Gem. Thank you. One question....When I run the code the first time, its executes slow, however each time thereafter it executes fairly fast. Any explanation? I'm just curious. Thanks again for your help!

I'm not sure but I think it has to do with caching. You sent a request to the server via the url. You get a response and I think that Excel or xmlhttp is caching the result in some way. Therefore the second time is faster because you use the same url and get the same result. But perhaps somebody has a different explanation.

Glad you got it working.
 
Upvote 0

Forum statistics

Threads
1,223,727
Messages
6,174,144
Members
452,547
Latest member
Schilling

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