I am trying to fetch the data from website & put it in the excel worksheet
Scenario: Webpage contains button with id=btnAllRun.
When i click on the button,table is generated dynamically containing information in tr tags inside it. Using macro i need to count no. of the such tr tags & put the count in worksheet.
Code:
Dim IE as Object
Sub Button_Click()
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
IE.Navigate URL
Do
DoEvents
Loop Until IE.ReadyState = 4 //waiting for the webpage to load
Set Elmt = IE.Document.getElementById("btnAllRun") //get button elmt for All Running
Elmt.Click //Clicking button
Do
DoEvents
Loop Until IE.ReadyState = 4
Set Tbl = IE.Document.getElementById("gvRunning") //gets table elmt containing tr tags
Sheets("XXX").Range("B36") = Tbl.Rows.Length - 1
When i am trying to run the macro i get 'Object Variable or with block not set' but when running the same macro in step debugging mode i get the correct results.
Any help on this would be greatly appreciated!!