• Skip to main content
  • Skip to header right navigation
  • Skip to site footer

My Online Training Hub

Learn Dashboards, Excel, Power BI, Power Query, Power Pivot

  • Courses
  • Pricing
    • Free Courses
    • Power BI Course
    • Excel Power Query Course
    • Power Pivot and DAX Course
    • Excel Dashboard Course
    • Excel PivotTable Course – Quick Start
    • Advanced Excel Formulas Course
    • Excel Expert Advanced Excel Training
    • Excel Tables Course
    • Excel, Word, Outlook
    • Financial Modelling Course
    • Excel PivotTable Course
    • Excel for Customer Service Professionals
    • Excel for Operations Management Course
    • Excel for Decision Making Under Uncertainty Course
    • Excel for Finance Course
    • Excel Analysis ToolPak Course
    • Multi-User Pricing
  • Resources
    • Free Downloads
    • Excel Functions Explained
    • Excel Formulas
    • Excel Add-ins
    • IF Function
      • Excel IF Statement Explained
      • Excel IF AND OR Functions
      • IF Formula Builder
    • Time & Dates in Excel
      • Excel Date & Time
      • Calculating Time in Excel
      • Excel Time Calculation Tricks
      • Excel Date and Time Formatting
    • Excel Keyboard Shortcuts
    • Excel Custom Number Format Guide
    • Pivot Tables Guide
    • VLOOKUP Guide
    • ALT Codes
    • Excel VBA & Macros
    • Excel User Forms
    • VBA String Functions
  • Members
    • Login
    • Password Reset
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member

Error scraping web data. Help with the VBA code|VBA & Macros|Excel Forum|My Online Training Hub

You are here: Home / Error scraping web data. Help with the VBA code|VBA & Macros|Excel Forum|My Online Training Hub
Avatar
sp_LogInOut Log In sp_Registration Register
sp_Search Search
Advanced Search|Last Search Results
Search
Forum Scope




Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_Search Search
sp_RankInfo
Lost password?
sp_CrumbsHome HomeExcel ForumVBA & MacrosError scraping web data. Help with …
sp_PrintTopic sp_TopicIcon
Error scraping web data. Help with the VBA code
Avatar
Peter Owen

New Member
Members
Level 0
Forum Posts: 1
Member Since:
February 16, 2019
sp_UserOfflineSmall Offline
1
February 16, 2019 - 6:42 am
sp_Permalink sp_Print

Hello Friends,

 

I am trying to automate using Excel Macro. Here is the breakup of objective-

a. Launch web page -  trweb.co.clark.nv.us

b. Populate web search form with data in column A

c. Click the submit button

d. Store required portion (CellData) of table data in column G

e. Loop to automate.

HERE IS MY CODE. I AM STUCK WITH STEP d.  The required output data has class=CellData and has multiple instances of this class. I tried capturing by tr tag as well but to no avail.  Looping hasn't been done in code yet as I haven't got positive response with Step d.  PLEASE HELP GUYS....

 

Sub PullSitus()

Dim IE As New InternetExplorer
Dim result As MSHTML.HTMLDocument
Dim doc As HTMLDocument

IE.Visible = True
IE.navigate "http://trweb.co.clark.nv.us/"

Do While IE.readyState <> READYSTATE_COMPLETE
Loop

IE.document.forms("Search").elements("Valid_ID").Value = ThisWorkbook.Sheets("Sheet1").Range("A" & 2).Value

'change value propety of "Valid_ID" element of "Search" form with data from cell $A2 of this workbook

IE.document.forms("Search").elements("Submit").Click

'Click on "Submit" element of "Search" form

Do While IE.readyState <> READYSTATE_COMPLETE
Loop

Set doc = IE.document

Set result = doc.getElementsByClassName("CellData").Item(4).innerText
ThisWorkbook.Sheets("Sheet1").Range("G" & 2) = result.Value

End Sub

Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1518
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
2
February 16, 2019 - 8:53 am
sp_Permalink sp_Print

Hi Peter,

Can you please supply the workbook with the data to be used in Step b, otherwise the form submission doesn't work.

Please explain what it is you are trying to do and what data you are trying to get from the site, it's hard to work out just by reading code.

Regards

Phil

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Catalin Bombea, Kim Knox, Nada Perovic, Othman AL MUTAIRI
Guest(s) 9
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 871
Purfleet: 412
Frans Visser: 346
David_Ng: 306
lea cohen: 219
Jessica Stewart: 205
A.Maurizio: 202
Aye Mu: 201
jaryszek: 183
Newest Members:
Othman AL MUTAIRI
Misael Gutierrez Sr.
Attif Ihsan
Kieran Fee
Murat Hasanoglu
Brett Dryland
Saeed Aldousari
Bhuwan Devkota
Kathryn Patton
Maria Conatser
Forum Stats:
Groups: 3
Forums: 24
Topics: 6222
Posts: 27293

 

Member Stats:
Guest Posters: 49
Members: 31916
Moderators: 3
Admins: 4
Administrators: Mynda Treacy, Philip Treacy, Catalin Bombea, FT
Moderators: MOTH Support, Velouria, Riny van Eekelen
© Simple:Press —sp_Information

Sidebar

Blog Categories

  • Excel
  • Excel Charts
  • Excel Dashboard
  • Excel Formulas
  • Excel PivotTables
  • Excel Shortcuts
  • Excel VBA
  • General Tips
  • Online Training
  • Outlook
  • Power Apps
  • Power Automate
  • Power BI
  • Power Pivot
  • Power Query
microsoft mvp logo
trustpilot excellent rating
Secured by Sucuri Badge
MyOnlineTrainingHub on YouTube Mynda Treacy on Linked In Mynda Treacy on Instagram Mynda Treacy on Twitter Mynda Treacy on Pinterest MyOnlineTrainingHub on Facebook
 

Company

  • About My Online Training Hub
  • Disclosure Statement
  • Frequently Asked Questions
  • Guarantee
  • Privacy Policy
  • Terms & Conditions
  • Testimonials
  • Become an Affiliate

Support

  • Contact
  • Forum
  • Helpdesk - For Technical Issues

Copyright © 2023 · My Online Training Hub · All Rights Reserved. Microsoft and the Microsoft Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. Product names, logos, brands, and other trademarks featured or referred to within this website are the property of their respective trademark holders.