A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
Thanks for sharing the details, David! Try a VBA code. With VBA, you can fetch live stock quotes directly into Excel 2024, even without Microsoft 365. This is actually one of the most flexible ways because you can control which stocks, how often they update, and how the data is displayed.
Here’s a clean approach:
VBA Method Using a Web API
Use Alpha Vantage (free API) as an example.
Go to Alpha Vantage, get a free API key (instant).
In Excel, open the VBA editor, press Alt + F11 in Excel. Click insert then module and paste this code:
Function GetStockPrice(symbol As String) As Double
Dim http As Object
Dim JSON As String
Dim price As Double
Dim apiKey As String
apiKey = "YOUR_API_KEY" ' <-- Replace with your Alpha Vantage API key
Set http = CreateObject("MSXML2.XMLHTTP")
http.Open "GET", "https://www.alphavantage.co/query?function=GLOBAL_QUOTE&symbol=" & symbol & "&apikey=" & apiKey, False
http.Send
JSON = http.responseText
' Parse the price from JSON
Dim startPos As Long, endPos As Long
startPos = InStr(JSON, """05. price"": """) + Len("""05. price"": """)
endPos = InStr(startPos, JSON, """")
If startPos > 0 And endPos > 0 Then
price = CDbl(Mid(JSON, startPos, endPos - startPos))
GetStockPrice = price
Else
GetStockPrice = CVErr(xlErrNA)
End If
End Function
Now you can use this as a function in Excel, in any cell type =GetStockPrice("MSFT")
Hit enter, the latest stock price appears.
To refresh every few minutes, add this code into the same module:
Sub RefreshStock()
ThisWorkbook.Sheets("Sheet1").Calculate
Application.OnTime Now + TimeValue("00:05:00"), "RefreshStock" ' every 5 minutes
End Sub
Run RefreshStock from the Macro button once to start automatic updates.
Note that you can replace "MSFT" with any valid stock ticker.
You can pull multiple tickers by writing formulas in multiple cells.
See if this helps. If you need further assistance just let me know.
Best regards,
Kimberly