In this Article
VBA web scraping makes sense in exactly one situation: the spreadsheet is the product, a person presses a button, and installing anything else on that machine is not an option. Within those limits it works, and WinHttpRequest is the object that supports an explicit proxy with credentials.
If you came here searching for vba web scraping, the short version is this: use WinHttp rather than MSXML2.XMLHTTP, pace the loop to about a request per second, and checkpoint the workbook every few rows. Excel is single-threaded, so the design goal is a job a user can interrupt without losing what it already collected.
Key Facts
- The stack in VBA: WinHTTP via WinHttp.WinHttpRequest.5.1 for fetching, string and regex handling, or Power Query for tables for parsing, and none; Internet Explorer automation is dead and should not be revived.
- Proxy setup is one object, not one line per request. Configure it once on the client and reuse that client, or you lose connection pooling and session coherence.
- The mistake that costs the most time here: msxml2.xmlhttp ignores setproxy.
- Rotation belongs to the session, not the request. One logical task keeps one exit; rotating mid-session breaks cookies and invites challenges.
- Use VBA when the consumer of the data is a spreadsheet, the volume is small, and installing anything else on the machine is not an option. Avoid it when the job is scheduled, large or needs rendering, where even a small Python script is a better home.
How do you route VBA requests through a proxy?
Configure the proxy on the client once, then reuse that client for every request in the session. Here is the minimal working form with authentication.
Dim http As Object
Set http = CreateObject("WinHttp.WinHttpRequest.5.1")
http.SetProxy 2, "gw.dataimpulse.com:823" ' 2 = named proxy
http.Open "GET", "https://example.com", False
http.SetCredentials "USER", "PASS", 1 ' 1 = proxy credentials
http.SetTimeouts 10000, 10000, 20000, 30000
http.Send
Dim html As String: html = http.responseText
Three details matter more than the syntax. The credentials belong to the gateway, not to the target site. The timeout is not optional, because a proxy adds a hop and a hung request holds a worker. And the client is the unit of identity: the same client means the same connection pool, the same cookies and, with a sticky session, the same exit address.
What does the 3-step workbook pipeline look like?
Keep three concerns apart, and debugging stops being guesswork. We call it the 3-step workbook pipeline.
| Part | What it owns | In VBA |
|---|---|---|
| 1. Transport | Connection, proxy, timeouts, retries, TLS | WinHTTP via WinHttp.WinHttpRequest.5.1 |
| 2. Parsing | Turning bytes into fields, and failing loudly when the markup moved | string and regex handling, or Power Query for tables |
| 3. Scheduling | Concurrency per host, pacing, backoff, deduplication | Your own worker pool or queue, bounded per target |
In a workbook these three parts map to something physical: the sheet is the queue and the output, the HTTP object is the transport, and your loop is the scheduler. Keeping a status column per row makes the separation visible, turns a restart into a filter, and shows progress without writing any interface code.
When a scrape breaks, the first question is which part broke. A non-200 status is transport. A 200 with empty fields is parsing, or a page that renders client-side. Success that decays over minutes is scheduling. Mixing the three into one function is why so many scrapers are rewritten rather than fixed.
Power Query is the honest alternative inside Excel for tabular sources: it handles pagination and refresh without VBA, though its proxy support follows Windows system settings rather than per-request configuration.
What goes wrong in VBA specifically?
Three problems account for most lost time in VBA, and none of them is the target blocking you.
MSXML2.XMLHTTP ignores SetProxy. The object most tutorials use has no usable proxy control in this scenario. WinHttpRequest is the one that exposes SetProxy and SetCredentials.
Everything blocks the UI. Synchronous calls freeze Excel. Keep batches small, write results to the sheet incrementally, and expect users to think it crashed if a run takes minutes.
Regex parsing breaks on markup changes. There is no DOM here. Pull values from JSON endpoints where they exist rather than pattern-matching HTML, which is the difference between a workbook that survives a redesign and one that does not.
None of these are exotic, and all of them look like a blocked scraper from the outside, which is why the first response is so often to buy proxies for a problem that lives in the client. Our guide to 403 Forbidden errors when scraping walks the isolation steps in order.
How do you keep an Excel scraper usable?
Batch, write incrementally, and give the user a visible stopping point. VBA is single-threaded, so the design goal is a job that can be interrupted without losing work.
Application.ScreenUpdating = False
For i = 2 To lastRow
ws.Cells(i, 3).Value = FetchField(ws.Cells(i, 1).Value)
If i Mod 25 = 0 Then
DoEvents ' keep Excel responsive
ThisWorkbook.Save ' checkpoint
End If
Application.Wait Now + TimeValue("0:00:01") ' pacing
Next i
Application.ScreenUpdating = True
One request per second with a checkpoint every twenty-five rows turns a scraper that people kill halfway into one that finishes. Keep the sheet as the queue: a status column per row makes a restart trivial and shows progress without any UI work.
What are the alternatives inside Excel?
Three, and the choice comes down to who presses the button.
| Approach | Use it for | Honest note |
|---|---|---|
| WinHttpRequest | Any request that needs an explicit proxy | The only common VBA object with SetProxy and SetCredentials |
| MSXML2.ServerXMLHTTP | Simple server-side style calls | Proxy control is limited and inconsistent; prefer WinHttp |
| Power Query | Tabular sources and scheduled refresh | No VBA at all, handles pagination well, but follows Windows proxy settings rather than per-request credentials |
| Internet Explorer automation | Nothing | Dead. Do not start new work on it in 2026 |
| A small external script | Anything scheduled or large | Python or PowerShell writing a CSV that Excel opens is usually less work than fighting VBA |
The test for staying in VBA is simple: if the workbook is the product and a person presses the button, stay. If a machine runs it on a schedule, the job has outgrown Excel.
When is VBA the wrong tool?
Use VBA when the consumer of the data is a spreadsheet, the volume is small, and installing anything else on the machine is not an option. Avoid it when the job is scheduled, large or needs rendering, where even a small Python script is a better home.
The deciding factor is maintenance, not capability. A crawler written in the language your team uses daily survives the next markup change; a clever one in an unfamiliar language is abandoned at the first breakage. If the honest answer is that VBA is the wrong home for this job, a small crawler elsewhere writing into the same database is a legitimate design, not a defeat.
Two things live outside this page because they are the same in every language, and repeating them here would only make them harder to keep current. Session and rotation rules, including why a journey must hold one sticky exit, are in proxy rotation best practices. What to do when a request is refused, and how to tell a network problem from a client problem, is in 403 Forbidden when scraping, and the legal framing is in is web scraping legal.
On the exit itself: rotating residential for public pages, sticky for journeys, datacenter for APIs and open data. DataImpulse residential is $1 per GB across 195 countries with country targeting included, and the comparison is in best proxies for web scraping.
Frequently Asked Questions
How do I set a proxy in VBA?
Configure it on the client object rather than per request: with WinHTTP via WinHttp.WinHttpRequest.5.1 you set the proxy host, port and credentials once, then reuse that client. Reusing it keeps the connection pool, the cookie jar and the exit address consistent, which is what makes a session look coherent.
Which library should I use for parsing in VBA?
string and regex handling, or Power Query for tables is the practical default. Keep parsing separate from fetching: the client owns the network and the parser owns the markup, so that a failure tells you immediately which of the two broke.
Do I need a headless browser for VBA?
Only when the fields are rendered client-side. Fetch the page plainly and search the HTML for one known value first: if it is there, skip the browser entirely. When you do need one, none; Internet Explorer automation is dead and should not be revived is the option in this ecosystem, and it costs an order of magnitude more per page in time and memory.
MSXML2.XMLHTTP ignores SetProxy?
The object most tutorials use has no usable proxy control in this scenario. WinHttpRequest is the one that exposes SetProxy and SetCredentials.
Is VBA a good choice for web scraping?
It is a good choice when the consumer of the data is a spreadsheet, the volume is small, and installing anything else on the machine is not an option. It is the wrong choice when the job is scheduled, large or needs rendering, where even a small Python script is a better home. The deciding factor is usually maintenance rather than raw capability: the scraper written in the language your team uses daily is the one that survives the next markup change.
Point your VBA client at a reliable exit
The snippet above works with one credential change: DataImpulse residential gives geo-accurate exits at $1 per GB across 195 countries, rotating or sticky, over HTTP, HTTPS and SOCKS5. Create an account and test one target from your VBA client before scaling the job.
Related: 403 Forbidden when scraping · Crawl4AI proxy setup · proxy setup in Go, Kotlin, Scala, Perl and Elixir.
Last updated: September 17, 2026.

State/City/Zip/ASN Targeting 



