VBA code to Enter Data to Webpage or IE

enter data to webpage
Table of Contents

VBA Enter Data into webpage – IE Automation using VBA GetElementByID function

What is it:

If you are trying to do ie automation or trying to enter data to webpage using VBA then this post if for you. We will show the step by step instructions on how to enter/fill data in ie using VBA.

Enter Data To WebpagePin

Why is it:

This is very helpful when you want to enter or fill multiple fields in a webpage regularly. Or if you want to login to website in a single click without using the browser’s default Remember My Password option etc.

How to enter data to webpage using vba

In this example we are using Excel VBA for IE Automation however you can use any VBA supported platform.

Step 1: Open the Excel workbook and got to VBA code builder (Alt + F11) and Open a New Module.

Enter Data To Webpage

Step 2: Copy and Paste the below code in it.

Private Sub wpieautologin()

Dim ie As SHDocVw.InternetExplorer

Set ie = New SHDocVw.InternetExplorer

ie.Visible = True 

ie.Navigate “https://www.askeygeek.com/wp-admin” ‘we are trying to login to askeygeek.com admin page



Loop Until ie.readystate = 4

‘ie READYSTATE has 5 different status codes, here we are using status 4:

‘Uninitialized = 0

‘Loading = 1

‘Loaded = 2

‘Interactive =3

‘Complete = 4 

Call ie.Document.GetElementByID(“user_login”).SetAttribute(“value”, “testUser”)

Call ie.Document.GetElementByID(“user_pass”).SetAttribute(“value”, “testPass12345”)

 ‘to find the “<input……/>” tag hyper link and to click the button

Set AllInputs = ie.Document.getelementsbytagname(“input”) ‘you can use any tagname as you wish

    For Each hyper_link In AllInputs

        If hyper_link.Name = “wp-submit” Then ‘you can use .name, .id etc


            Exit For

        End If




Loop Until ie.readystate = 3



Loop Until ie.readystate = 4

End Sub

Step 3: Click the Run button or F5.(Also you can insert a button/shape in excel sheet then right click and assign this macro to run every time.)

Enter Data To Webpage

Notes 1: Make sure ‘Microsoft Internet Controls’ is enabled from the Tools – References.

Ie AutomationPin

Notes 2: Right click the webpage to and click View source to find the GetElement values


Picture of Anson Antony
Anson Antony
Anson is a contributing author and founder at www.askeygeek.com. Learning anything new has always been his passion, askeygeek.com is an outcome of his passion for technology and business. He has got a decade of versatile experience in Business Process Outsourcing, Finance & Accounting, Information Technology, Operational Excellence & Business Intelligence. During the tenure, he had worked for organizations like Genpact, Hewlett Packard, M*Modal and Capgemini in various roles and responsibilities. Outside business and technology, he is a movie buff who spends hours together watching and learning Cinema and a Film Maker too!

7 Responses

  1. hi team, i need to fill the data in Browser tab, which is already opened and navigated to the exact page, where i need to fill my data, please provide the VBA code to deal with this session.

  2. Hi,

    I have to click on a additional message from web page, can you help me with the code. I’m struck at the this final part of clicking ok on it

  3. Can you help me here?
    There is no id or value set in the following lines of code, how do I insert say into the “lastnameFilter” or “firstnameFilter”?

    Learner’s ID

    First Name

    Family Name



  4. I am getting error at Call ie.Document.GetElementByID(“user_login”).SetAttribute(“value”, “testUser”)

    Error: Run-time error 424: object required.

    Can you please help me.

Leave a Reply

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

You Made It,
Don't Close!

Get Up To 60,000 UberTTS Character Credits for Free!!!

This popup won’t show up to you again!!!

Share to...