STOCKHISTORY function
Downloads historical prices for a stock, fund or currency pair from Microsoft’s data service.
Syntax
=STOCKHISTORY(stock, start_date, [end_date], [interval], [headers], [property0], …)
How to use STOCKHISTORY in Excel, step by step
STOCKHISTORY doesn’t run in a web practice sheet because it downloads stock prices from Microsoft’s data service. Follow these steps in Excel itself.
You’ll need
- Microsoft 365 (Excel for Windows, Mac or the web)
- Signed in with a Microsoft 365 account
- An internet connection
- Choose the ticker. Type a symbol such as MSFT, or "XNAS:MSFT" to pick the exchange. Currency pairs look like "USD/EUR".
- Pick dates. Put a start date in B1 and an end date in B2 (real dates, not text).
- Write the formula. Type =STOCKHISTORY("MSFT",B1,B2). It spills a table of Date and Close.
- Choose interval and columns. =STOCKHISTORY("MSFT",B1,B2,0,1,0,1,2,3,4,5) gives daily rows (interval 0) with headers and Date, Close, Open, High, Low, Volume.
- Chart it. Select the spilled range › Insert › Line chart.
Example
=STOCKHISTORY("MSFT","2024-01-01","2024-01-31")
Result: A table of dates and closing prices
interval: 0 daily, 1 weekly, 2 monthly.
Data can be delayed and isn’t for trading decisions.