Excel VBA not retrieving data as before [on hold]

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


Excel VBA not retrieving data as before [on hold]



I want to pull data from website "http://result.biselahore.com/" to Excel Sheet by entering roll number "217449". After entering Roll Number it goes to the result card page with detail subject wise marks.



To get subject-wise marks from the next page and paste it on excel, the following code is not working and it gives error number 91, "Object variable With block variable not set".



Here is my entire code:


Sub WData()



Do Until ActiveCell.Value = "100000"



Dim IE As New InternetExplorer



Dim DOCS As HTMLDocument



Dim str, str1, str2, str3, str4, str5 As String



IE.navigate "http://result.biselahore.com/"



IE.Visible = True



Do



DoEvents



Loop Until IE.readyState = READYSTATE_COMPLETE



IE.document.getElementById("rollNum").Value = ActiveCell.Value



IE.document.forms(0).submit



Do While IE.Busy



DoEvents



Loop



Set DOCS = IE.document



Do While DOCS.readyState <> "complete"



DoEvents



Loop



str = IE.document.getElementsByTagName("td")(4).innerText



str1 = IE.document.getElementsByTagName("td")(7).innerText



str2 = IE.document.getElementsByTagName("td")(9).innerText



str3 = IE.document.getElementsByTagName("td")(20).innerText



str4 = IE.document.getElementsByTagName("td")(23).innerText



str5 = IE.document.getElementsByTagName("td")(25).innerText



str6 = IE.document.getElementsByTagName("td")(27).innerText



str7 = IE.document.getElementsByTagName("td")(37).innerText



str8 = IE.document.getElementsByTagName("td")(38).innerText



str9 = IE.document.getElementsByTagName("td")(42).innerText



str10 = IE.document.getElementsByTagName("td")(43).innerText



str11 = IE.document.getElementsByTagName("td")(47).innerText



str12 = IE.document.getElementsByTagName("td")(48).innerText



str13 = IE.document.getElementsByTagName("td")(52).innerText



str14 = IE.document.getElementsByTagName("td")(53).innerText



str15 = IE.document.getElementsByTagName("td")(57).innerText



str16 = IE.document.getElementsByTagName("td")(58).innerText



str17 = IE.document.getElementsByTagName("td")(62).innerText



str18 = IE.document.getElementsByTagName("td")(63).innerText



str19 = IE.document.getElementsByTagName("td")(71).innerText



Dim lastrow As Integer



lastrow = Worksheets(1).Range("b" & Worksheets(1).Rows.Count).End(xlUp).Row + 1



Cells(lastrow, 2).Value = Trim(str)



Cells(lastrow, 3).Value = Trim(str1)



Cells(lastrow, 4).Value = Trim(str2)



Cells(lastrow, 5).Value = Trim(str3)



Cells(lastrow, 6).Value = Trim(str4)



Cells(lastrow, 7).Value = Trim(str5)



Cells(lastrow, 8).Value = Trim(str6)



Cells(lastrow, 9).Value = Trim(str7)



Cells(lastrow, 10).Value = Trim(str8)



Cells(lastrow, 11).Value = Trim(str9)



Cells(lastrow, 12).Value = Trim(str10)



Cells(lastrow, 13).Value = Trim(str11)



Cells(lastrow, 14).Value = Trim(str12)



Cells(lastrow, 15).Value = Trim(str13)



Cells(lastrow, 16).Value = Trim(str14)



Cells(lastrow, 17).Value = Trim(str15)



Cells(lastrow, 18).Value = Trim(str16)



Cells(lastrow, 19).Value = Trim(str17)



Cells(lastrow, 20).Value = Trim(str18)



Cells(lastrow, 21).Value = Trim(str19)



IE.Quit



Set IE = Nothing



Selection.Offset(1, 0).Select



Loop



End Sub



My Desired OUTPUT:



Subject Marks Subject Marks Subject Marks Subject Marks



URDU 68 62 ENGLISH 75 70 ISLAMIAT 50 49 MATHEMATICS 75 75



PHYSICS 60 59 CHEMISTRY 60 60 BIOLOGY 58 59



Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.





Please read: Under what circumstances may I add “urgent” or other similar phrases to my question, in order to obtain faster answers?
– Pᴇʜ
Jul 23 at 8:55





If it's not pulling data as before, maybe it's because the website changed. Make sure TD(24) is still there for that case. Try with other numbers in the past and see what happens.
– Foxfire And Burns And Burns
Jul 23 at 9:50





@user2332060 we don't send emails here. Instead please edit your original question (no code in comments please) and add your code there formatted as code block. Therefore indent your code at least 4 spaces (eg. by selecting it and pressing Ctrl + K). • Also you should show the source code of the web page you trying to scrape. We need a Minimal, Complete, and Verifiable example or at least something that is very close to that.
– Pᴇʜ
Jul 23 at 12:19







If your code is not indented in your editor, it is recommended that you make that change so it is easier to work with for you. You can then additionally copy that improvement to the code here, so that it is easier for your readers to help you.
– halfer
Jul 23 at 17:35







@user2332060 The code you showed in the question is not valid. At least one quote " is missing. Make sure the code in the question is exactly the code that you use. Also please indent your code correctly and tell in which line you get the error.
– Pᴇʜ
Jul 24 at 6:57




"




Popular posts from this blog

Arduino Mega cannot recieve any sketches, stk500_recv() programmer is not responding

Visual Studio Code: How to configure includePath for better IntelliSense results

C++ virtual function: Base class function is called instead of derived