Web Automation - Retrieve company Names - Ticker
Sub Update_Ticker_In_Searchbox_and_Retrieve_CompanyName_MultipleExplorers()
Dim sh As Worksheet
Set sh = ThisWorkbook.Sheets("Yahoo_All Elements")
MaxRow = sh.Range("A" & Rows.Count).End(xlUp).Row
sh.Range(Cells(2, 2), Cells(sh.UsedRange.Rows.Count + 2, 2)).ClearContents
Dim IE As InternetExplorer
r = 2 ' As ticker symbols starts from 2nd row
Do Until sh.Range("A" & r).Value = ""
Set IE = New InternetExplorer
IE.Visible = True
IE.navigate "https://finance.yahoo.com/"
Application.Wait (Now + TimeValue("00.00.06"))
Ticker = sh.Range("A" & r).Value
Set doc = IE.document
IE.document.getElementsByTagName("input")("yfin-usr-qry").Value = Ticker
IE.document.getElementById("header-desktop-search-button").Click
Application.Wait (Now + TimeValue("00.00.05"))
Set Cnames = IE.document.getElementsByClassName("D(ib) Fz(18px)")
For Each Cname In Cnames
sh.Cells(r, 2).Value = Cname.innerText
sh.Columns(2).AutoFit
r = r + 1
Next
IE.Quit
Set IE = Nothing
Loop
MsgBox "Hi Process Completed"
End Sub