Sub getDataForExcel() Dim ie As InternetExplorer
Dim ht As HTMLDocument
Dim wb As Workbook
Dim ws As Worksheet
Dim rng As Range
Dim symbol As String
Dim n As Integer
Dim lastrow As Long
'Dim ltpPrice As Integer
Set wb = ActiveWorkbook
Set ws = Sheets("Sheet1")
'ws.Activate
'Last row find
lastrow = ws.Cells(Rows.Count, "A").End(xlUp).Row
Set rng = ws.Range("A2:A" & lastrow)
n = 2
For Each x In rng
symbol = x
Set ie = New InternetExplorer
ie.Visible = True
ie.navigate ("https://nseindia.com/get-quotes/equity?symbol=" & symbol & "")
Do Until ie.readyState = READYSTATE_COMPLETE
DoEvents
Loop
Set ht = ie.Document
Set ltpPrice = ht.getElementById("quoteLtp")
MsgBox ltpPrice
'i = 1
'For Each ltp In ltpPrice
' Sheet1.Cells(i, 2).Value = ltp.innerText
' i = i + 1
'Next
Next x
End Sub
Aucun commentaire:
Enregistrer un commentaire