How to Follow Link on Web Page Automatically with VBA

Watch the video before you study the code to follow a link on a web page automatically with VBA:

A user wants to open a website automatically and then click on a specific link also automatically so that he can scrape data from that specific page and get it into an Excel worksheet. We have shown earlier how to scrape web page data automatically using VBA. Today we’ll learn how to follow a link on a web page automatically with VBA. The complete VBA code is given below:

Sub followWebsiteLink()
‘From Tools —-> References activate
‘1. Microsoft HTML Object Library
‘2. Microsoft Internet Controls

Dim ie As InternetExplorer
Dim html As HTMLDocument
Dim Link As Object
Dim ElementCol As Object

Application.ScreenUpdating = False

Set ie = New InternetExplorer
ie.Visible = True

ie.navigate “”

Do While ie.readyState <> READYSTATE_COMPLETE
Application.StatusBar = “Loading website…”

Set html = ie.document
Set ElementCol = html.getElementsByTagName(“a”)

For Each Link In ElementCol
If Link.innerHTML = “Advertising” Then
End If
Next Link

Set ie = Nothing
Application.StatusBar = “”
Application.ScreenUpdating = True
End Sub

Download a sample Excel file:

Published by

Dinesh Kumar Takyar

Welcome to! My aim is to help you learn MS Excel including VBA. I always felt that a good way to learn something was to find solutions to problems in that domain. That is why I share these Excel videos with you. Mostly these are questions asked during my corporate training sessions. I've been training individuals and companies in computers since 1991. I did my B. Sc. (Vordiplom), M. Sc. (Diplom) and Ph.D. (Dr. rer. nat.) from Hamburg, Germany. The best thing about solving some of my visitor's questions is that I also gain new insights. For more Excel VBA solutions you may like to visit my YouTube channel: For a structured Excel VBA training course online you can visit:

One thought on “How to Follow Link on Web Page Automatically with VBA”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.