Connecting Excel to the Web: Webscraping with VBA
Use XMLHTTP to fetch pages/APIs and parse the result.
HTTP GET (JSON API)
Function HttpGet(ByVal url As String) As String Dim x As Object: Set x = CreateObject("MSXML2.XMLHTTP") x.Open "GET", url, False x.send If x.Status = 200 Then HttpGet = x.responseText End Function
Parse JSON via a helper (e.g., VBA-JSON) and write to a sheet.
HTML scraping basics
- Inspect with browser dev tools
- Use patterns/XPath or regular expressions carefully
- Respect terms of service and robots
Work faster with the VBA Assistant
Create, explain, and improve your VBA code with examples, comments, and best practices—directly in your workflow.
