This video will give you an idea regarding how to get the share details into Excel for our own manipulation purpose. The code is given below.
=========================
Enum READYSTATE
READYSTATE_UNINITIALIZED = 0
READYSTATE_LOADING = 1
READYSTATE_LOADED = 2
READYSTATE_INTERACTIVE = 3
READYSTATE_COMPLETE = 4
End Enum
Public Interval As Date
Sub Mymacro()
'Dim ie1 As InternetExplorer
Dim ie1 As Object
'Declare variables
Dim x, r, i As Long
Dim a, y, s As String
Dim n As Integer
'to refer to the HTML document returned
Dim html1 As HTMLDocument
Dim wb As Workbook: Set wb = ThisWorkbook
Dim ws As Worksheet
Set ws = wb.Sheets("VBA")
n = ws.Range("A:A").Cells.SpecialCells(xlCellTypeConstants).Count
If n ANGL.BR.OPEN 2 Then
GoTo Exit1
End If
For i = ws.Cells(1, "F").Value To n
ws.Cells(1, "F").Value = i
ws.Cells(i, "A").Interior.Color = vbYellow
Set ie1 = Nothing
'Set ie1 = New InternetExplorer
Set ie1 = CreateObject("InternetExplorer.Application")
'ie1.Visible = False
If ws.Cells(i, "A").Value = "BTC" Then
ie1.navigate "https://www.*.com/*/" & ws.Cells(i, "A").Value & "usd"
Else
ie1.navigate "https://www.*.com/*/" & ws.Cells(i, "A").Value
End If
'Wait until IE is done loading page
Do While ie1.READYSTATE ANGL.BR.OPENANGL.BR.CLOSE READYSTATE_COMPLETE
Application.StatusBar = "Trying to go to..." & ws.Cells(i, "A").Value
DoEvents
Loop
Set html1 = Nothing
'show text of HTML document returned
Set html1 = ie1.document
'close down IE and reset status bar
ie1.Quit
Set ie1 = Nothing
Application.StatusBar = ""
a = html1.DocumentElement.innerHTML
x = InStr(a, "price"":""")
y = Mid(a, x + 8, 15)
ws.Cells(i, "B").Value = Mid(y, 1, InStr(y, """") - 1)
r = InStr(a, "label""ANGL.BR.CLOSE52 Week RangeANGL.BR.OPEN/smallANGL.BR.CLOSE")
s = Mid(a, r + 72, 30)
If r ANGL.BR.CLOSE 0 Then
ws.Cells(i, "C").Value = Mid(s, 1, InStr(s, "ANGL.BR.OPEN/") - 1)
End If
r = InStr(a, "label""ANGL.BR.CLOSEMarket CapANGL.BR.OPEN/smallANGL.BR.CLOSE")
s = Mid(a, r + 69, 30)
If r ANGL.BR.CLOSE 0 Then
ws.Cells(i, "D").Value = Mid(s, 1, InStr(s, "ANGL.BR.OPEN/") - 1)
End If
r = InStr(a, "label""ANGL.BR.CLOSEEPSANGL.BR.OPEN/smallANGL.BR.CLOSE")
s = Mid(a, r + 62, 30)
If r ANGL.BR.CLOSE 0 Then
ws.Cells(i, "E").Value = Mid(s, 1, InStr(s, "ANGL.BR.OPEN/") - 1)
End If
Set html1 = Nothing
a = ""
x = ""
y = ""
ws.Cells(i, "F").Value = Now
ws.Cells(i, "A").Interior.Color = vbGreen
Next i
Exit1:
ws.Cells(1, "F").Value = 2
Call Mymacro_timer
End Sub
Sub Mymacro_timer()
Interval = Now + TimeValue("00:00:05")
Application.OnTime Interval, "Mymacro"
End Sub
Sub stop_Mymacro()
'Ingore errors
On Error Resume Next
Application.OnTime earliesttime:=Interval, procedure:="Mymacro", schedule:=False
End Sub
Информация по комментариям в разработке