• 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
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member

Error on VBA code for pull or extract data from HTML Element in Excel|VBA & Macros|Excel Forum|My Online Training Hub

You are here: Home / Error on VBA code for pull or extract data from HTML Element in Excel|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 on VBA code for pull or extra…
sp_PrintTopic sp_TopicIcon
Error on VBA code for pull or extract data from HTML Element in Excel
Avatar
chia hoo Ray Hee

New Member
Members
Level 0
Forum Posts: 2
Member Since:
June 16, 2020
sp_UserOfflineSmall Offline
1
June 16, 2020 - 4:10 pm
sp_Permalink sp_Print

Hello everyone,

I try to run the VBA code as below but it is compile error "Run time error "424":Object require" on Set GetJSON = JSONConverter.ParseJson(.responseText).

Appreciate someone can guide me to find out what is the error mean for?

Sub Test() Const sURL As String = "https://eservices.mas.gov.sg/api/action/datastore/search.json?resource_id=95932927-c8bc-4e7a-b484-68a66a24edfe&fields=end_of_day,jpy_sgd_100&limit=10&sort=end_of_day%20desc" Dim a, ws As Worksheet, json As Object, colData As Collection, m As Long Set ws = ThisWorkbook.Worksheets("Sheet1") Set json = GetJSON(sURL) Set colData = json("result")("records") a = CollectionToArray(colData) With ws .Cells.ClearContents .Range("A1").Resize(1, 2).Value = Array("End Of Day", "Amount") .Range("A2").Resize(UBound(a, 1), UBound(a, 2)).Value = a End With Set json = Nothing: Set colData = Nothing End Sub Function GetJSON(ByVal sURL As String) As Object Dim http As MSXML2.XMLHTTP60 Set http = New MSXML2.XMLHTTP60 With http .Open "Get", sURL, False .setRequestHeader "User-Agent", "Mozilla/5.0" .send Set GetJSON = JSONConverter.ParseJson(.responseText) End With End Function Function CollectionToArray(c As Collection) As Variant() Dim a(), i As Long, j As Long ReDim a(1 To c.Count, 1 To 2) For i = 1 To c.Count a(i, 1) = c.Item(i)("end_of_day") a(i, 2) = c.Item(i)("jpy_sgd_100") Next i CollectionToArray = a End Function
sp_AnswersTopicSeeAnswer See Answer
Avatar
Velouria
London or thereabouts
Moderator
Members


Trusted Members

Moderators
Level 4
Forum Posts: 648
Member Since:
November 1, 2018
sp_UserOfflineSmall Offline
2
June 16, 2020 - 6:30 pm
sp_Permalink sp_Print

I suspect you just forgot to name the module you borrowed JSONConverter

sp_AnswersTopicAnswer
Answers Post
Avatar
chia hoo Ray Hee

New Member
Members
Level 0
Forum Posts: 2
Member Since:
June 16, 2020
sp_UserOfflineSmall Offline
3
June 17, 2020 - 1:14 am
sp_Permalink sp_Print

Velouria, thank you for your help! it works after i named the module.

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online:
Guest(s) 11
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 873
Purfleet: 414
Frans Visser: 346
David_Ng: 306
lea cohen: 222
Jessica Stewart: 215
A.Maurizio: 202
Aye Mu: 201
jaryszek: 183
Newest Members:
Anthony van Riessen
Erlinda Eloriaga
Abisola Ogundele
MARTYN STERRY
Rahim Lakhani
Ngoc Qui Nguyen
Clement Mansfield
Rose .
Bindu Menon
Baruch Zemer
Forum Stats:
Groups: 3
Forums: 24
Topics: 6352
Posts: 27779

 

Member Stats:
Guest Posters: 49
Members: 32319
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.