VBA: Validating URLs inside Excel is essential for SEO audits, marketing lists, e‑commerce catalogs, and large datasets. While external tools make bulk validation easier, many advanced Excel users prefer an in‑sheet solution they can customize and automate.
In this tutorial, you’ll learn how to build your own URL validation tool using VBA — allowing Excel to check link status codes directly.
Why Use VBA for URL Validation?
A custom VBA script allows you to:
- Validate URLs without leaving Excel
- Automate checks for thousands of rows
- Customize timeout, color‑coding, and output
- Integrate with existing macros or dashboards
- Avoid manual copy/paste into external tools
Great for SEO teams, analysts, developers, and automation workflows.

1. Create a Simple VBA Function to Check URLs
Follow these steps:
Step 1 — Open the VBA Editor
- Press ALT + F11
- Go to Insert → Module
Step 2 — Paste This Code
Function CheckURLStatus(url As String) As String
Dim http As Object
Set http = CreateObject(“MSXML2.XMLHTTP”)
On Error GoTo ErrorHandler
http.Open “GET”, url, False
http.send
CheckURLStatus = http.Status & ” – ” & http.statusText
Exit Function
ErrorHandler:
CheckURLStatus = “Invalid or unreachable”
End Function
What This Code Does
- Sends a request to each URL
- Returns the HTTP status code (200, 404, 500, etc.)
- Catches errors for broken or malformed links
2. Use the Function in Excel
Once saved, you can use it like any built‑in function:
=CheckURLStatus(A2)
Where A2 contains a URL.
Excel will return results like:
- 200 – OK
- 301 – Moved Permanently
- 404 – Not Found
- Invalid or unreachable
3. Add Conditional Formatting for Better Visibility
To highlight broken links:
Go to:
Home → Conditional Formatting → Highlight Cell Rules → Text That Contains
Use conditions like:
- “404” → Red
- “500” → Orange
- “Invalid” → Red
This creates a clean visual audit of URL health.

4. Add a Looping Macro for Bulk Validation
If your dataset is huge, use this macro:
Sub BulkURLValidator() Dim lastRow As Long Dim i As Long lastRow = Cells(Rows.Count, “A”).End(xlUp).Row For i = 2 To lastRow Cells(i, 2).Value = CheckURLStatus(Cells(i, 1).Value) DoEvents Next i End Sub
How it works
- Takes every URL in column A
- Writes validation results in column B
- Loops through thousands of rows automatically
5. Tips for Faster & More Reliable Validation
✔ Use HTTPS URLs
Some HTTP websites block automated requests.
✔ Remove tracking parameters
Example:
?utm_source=facebook
✔ Add short delays in massive datasets
This prevents request blocking.
✔ Always test on a smaller sample first
6. Limitations of VBA‑Based Validators
While VBA is powerful, it has some limitations:
- Slower than dedicated tools
- Can be blocked by some servers
- Doesn’t provide redirect chains
- Depends on MSXML libraries
- Requires macro permissions
For large‑scale validation (10,000+ URLs), dedicated tools remain more efficient.

Conclusion
Using VBA to build a custom URL validator gives Excel users powerful in‑sheet automation. You can check link health, automate bulk validation, and integrate the logic into SEO or data‑cleanup workflows.
This DIY solution is perfect for technical Excel users who want direct control and custom logic — all without leaving their spreadsheet.
