Gasman
Enthusiastic Amateur
- Local time
- Today, 23:37
- Joined
- Sep 21, 2011
- Messages
- 16,556
Is that addressed to me?I was hoping downloading was what you were doing. I run to run the code but I wasn't familiar with all your functions. Can you give me a hint about how to use it? If I can make it work, I can certainly make changes to suit my needs, if I have to. Thanks for following up on this.
I wrote this in Excel, but you should be able to modify. You will need to get your own key. Review their documentation as to which type of download you want. They have a few.
strAPIKey is a global variable
Then this is called with
Code:
Call GetData(strTicker)
Basically, build a url with the correct key and ticker value, plus type of download.
Code:
Sub GetData(pstrTicker As String)
'
Dim strConnection As String
'strConnection = "https://www.alphavantage.co/query?function=TIME_SERIES_WEEKLY&symbol=" & pstrTicker & "&apikey=" & strAPIKey & "&datatype=csv&outputsize=compact"
' Amended to one day figure as getting out of memory errors 260620
strConnection = "https://www.alphavantage.co/query?function=GLOBAL_QUOTE&symbol=" & pstrTicker & "&apikey=" & strAPIKey & "&datatype=csv&outputsize=compact"
Debug.Print strConnection
'Application.ScreenUpdating = False
Sheets("Data").Select
Cells.Clear
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;" & strConnection & "" _
, Destination:=Sheets("Data").Range("$A$1"))
.Name = ""
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 65001
.TextFileStartRow = 2
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = False
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = True
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
End Sub