Home Excel Powerpoint Word Outlook Error Codes

VBA Useful Codes

Welcome to the World of VBA
Home > VBAUsefulCodes

Get Specific Data from Webpage Using Excel VBA


This demo is useful, when you want to extract some portion of data from a large webpage, instead of downloading all the source code.

' Fetch Specific Part from the webpage
' In this demo we fetch a data from specific id

Private Sub CommandButton1_Click()
Dim IE As Object

' Create InternetExplorer Object
Set IE = CreateObject("InternetExplorer.Application")

' You can Change Next line To False to hide Internet explorer window
IE.Visible = True

' URL to get data from
IE.Navigate "https://www.google.co.in/"

' Statusbar
Application.StatusBar = "Loading, Please wait..."

' Wait while IE loading...
Do While IE.Busy
Application.Wait DateAdd("s", 1, Now)
Loop

Application.StatusBar = "Searching for value. Please wait..."

Dim dd As String

' Data from specific ID - "_eEe"

dd = IE.Document.getElementById("_eEe").innerText

MsgBox dd

' Show IE
IE.Visible = True

' Clean up
Set IE = Nothing

Application.StatusBar = ""
End Sub

Subscribe

Enter your e-mail below and get notified on the latest blog posts.




Tags

VBA Outlook KPI Excel Alt+F11 Dashboards Macros Recording Graphs Automation Developer WaterFall Powerpoint Charts Pivot Tables Forecast Charts


Follow Us