Jarric avatar

VBA Excel Script for fetching GRC prices

jarric

Published: 22 Feb 2018 › Updated: 22 Feb 2018VBA Excel Script for fetching GRC prices

VBA Excel Script for fetching GRC prices

Hi there,

I was a bit bored today, so I wrote simple script helping me to calculate prices of Gridcoin in USD and PLN in Excel.

Basically I keep track cryptos I own and haven't sold yet. I tested this script in Excel 2016, I have no idea if this will work in Libre/Open Office. Data is fetched from CoinMarketCap from their HTTP API, making a HTTP GET request. By that I'm receiving a JSON string which is parsed by external VBA script, which is there on GitHub licenced on MIT. Then I'm just extracting data from the JSON (parsed object is an array of dictionaries, VBA indexes arrays from "1") and write them to designated cells.
If you want to change fetched crypto then change "gridcoin" in the CoinMarketCapUrl variable to any other crypto like dogecoin or steem (it might be case sensitive, didn't check that)
Feel free to use this script in your workseets.

Cheers!

Sub GetData()

Const CoinMarketCapUrl As String = "https://api.coinmarketcap.com/v1/ticker/gridcoin/?convert=PLN"

Dim request As Object
Dim result As String
Dim json As Object
Dim usd As String
Dim pln As String

Set request = CreateObject("MSXML2.XMLHTTP")

usd = " "
pln = " "


With request
    .Open "GET", CoinMarketCapUrl, True
    .Send
End With

result = request.ResponseText

Set json = JsonConverter.ParseJson(result)

usd = json(1)("price_usd")

pln = json(1)("price_pln")

Range("L2").Value = usd

Range("N2").Value = pln


End Sub


Leave VBA Excel Script for fetching GRC prices to:

Written by

Programmer/Electronic Hobbyist/Weeb

Read more #gridcoin posts


Best Posts From Jarric

We have not curated any of jarric's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.

More Posts From Jarric