title: VBA - API call displayed in Excel
body: <p>I am trying to show prices of specific cryptocurrencies in an Excel sheet. I am extracting the JSON data from the API of CoinMarketCap - <a href="https://api.coinmarketcap.com/v1/ticker/" rel="nofollow noreferrer">https://api.coinmarketcap.com/v1/ticker/</a></p>
  
  <p>Ultimately, I am trying to get the price of Ripple (line 16), and then set cell B1 in my Excel sheet to display the price of ripple (line 17).</p>
  
  <p>This is my script, but it is not working for some reason.</p>
  
  <pre><code>Sub test()
  
  Dim httpObject As Object
  Set httpObject = CreateObject("MSXML2.XMLHTTP")
  
  sURL = "https://api.coinmarketcap.com/v1/ticker/"
  
  sRequest = sURL
  httpObject.Open "GET", sRequest, False
  httpObject.Send
  sGetResult = httpObject.ResponseText
  
  Dim oJSON As Object
  Set oJSON = JsonConverter.ParseJson(sGetResult)
  
    If oJSON.Name = "Ripple" Then
    B1 = oJSON("Ripple")("price_usd")
  
  End If
  End Sub
  </code></pre>
  
  <p>The API call is successful (I believe), but I get syntax errors etc. Hope anybody is able to help. Thanks in advance</p>
  
  <p>EDIT: This is Microsoft Excel 2010</p>
  
  <p><strong>EDIT 2:</strong> It is lines 16 and 17 (respectively <code>If oJSON.Name...</code> and <code>B1 = oJSON(...</code> that poses the problem, but I have been unable to solve it/find the error as of now. See comments for Run Time Error etc.</p>
  
  <p>EDIT 3: I believe I have made a mistake in lines 16 and 17 by referring to oJSON and not the item (sItem). However, even after changing this (e.g. <code>If sItem.Name = "Ripple" Then...</code>), it is still not working.</p>
  
  <p>EDIT 4: I believe I also tagged the excel-cell in the wrong manner. Instead of simply writing <code>B1 = ...</code>, I am now writing <code>Range.("B1").Value = ...</code>, which worked in a test.</p>