vba code for automation

icssushil

New Member
Joined
Jun 8, 2019
Messages
5
Dear SirI want to enter data (roll numbers) from excel in site http://rajresults.nic.in/resbserx19.htm and the and extract the data received in excel. I had tried to write the code which is given below but unable to extract percentage or data from site. Please help.
Code:
Private Sub CommandButton1_Click()
Dim IE As ObjectSet IE = CreateObject("InternetExplorer.Application")
IE.navigate "http://rajresults.nic.in/resbserx19.htm"
IE.Visible = True
While IE.busyDoEvents 'wait until IE is done loading page.
Wend
IE.document.all("roll_no").Value = ThisWorkbook.Sheets("Sheet1").Range("B2")
Set doc = IE.document    
Do While doc.ReadyState <> "complete": DoEvents: Loop    doc.GetElementsByName("B1")(0).Click        strVal = IE.document.all("Percentage").Item(0).innerText    
ThisWorkbook.Sheets("Sheet1").Range("C2").Value = strVal    
End Sub
 
Last edited by a moderator:

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
.
The macro, re-written as below ... got me to the first screen requesting the Roll Number and gave me an error for the false number I used :

Code:
Option Explicit


Sub CommandButton1_Click()
Dim IE As Object
Dim doc As Object
Dim strVal As String
Set IE = CreateObject("InternetExplorer.Application")


IE.navigate "http://rajresults.nic.in/resbserx19.htm"
IE.Visible = True


While IE.busy
    DoEvents 'wait until IE is done loading page.
Wend


IE.document.all("roll_no").Value = ThisWorkbook.Sheets("Sheet1").Range("B2")
Set doc = IE.document


Do While doc.ReadyState <> "complete": DoEvents: Loop


doc.GetElementsByName("B1")(0).Click
strVal = IE.document.all("Percentage").Item(0).innerText
ThisWorkbook.Sheets("Sheet1").Range("C2").Value = strVal


End Sub


Put your real Roll Number and Name in the appropriate cells and see what happens.
 
Upvote 0
I Put the roll no 1706641 in B2 but not getting its percentage in C2. I also need percentage of all the roll numbers entered in B2 in column C2. Please help.
I am getting run time error '424' object required.
Note; Roll numbers are increasing by 1.
Thanks
 
Upvote 0
.
I also need percentage of all the roll numbers entered in B2 in column C2. Please help.

Sounds like there is a lot more going on with your code than I fully understand.

You'll need to explain is better detail because I don't understand the importance of the 'percentages' or what the
expected outcome is.
 
Upvote 0
Sir, my requirement is that I have roll numbers of few students who have appeared in Board exams. I want to see their results online (http://rajresults.nic.in/resbserx19.htm) and want to store their scored percentages in excel. In one column i will write all the roll numbers like
Roll No. Percentage
1706641 90
1706642 94.5
1706643 85.5
and so on
I need a macro which will pick one roll number at a time and after checking the result its scored percentage will be entered in excel next to its roll no.
I hope I have make my requirement clear this time.
Thanks and Regards
 
Upvote 0
.
The PERCENTAGE is downloaded from the website you've listed in the code ?

If that is the scenario, regretfully I am not familiar with obtaining data from a website. There are many other volunteers on this
and other forums who are familiar. Hopefully someone else can assist you.

Thank you for your understanding.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top