STOCKHISTORY
Pull historical stock prices and trading data directly into Excel with the STOCKHISTORY function.
Syntax
=STOCKHISTORY(symbol, start_date, end_date, interval, headers)
Returns: Array Arguments
| Argument | Required | Description |
|---|---|---|
| symbol | Yes | The stock or security symbol for which you want to retrieve historical data. |
| start_date | Yes | The start date for the historical data range. |
| end_date | Yes | The end date for the historical data range. |
| interval | Yes | The interval at which the data is provided (e.g., daily, weekly, monthly). |
| headers | Yes | A boolean value (TRUE/FALSE) that indicates whether headers should be included in the output. TRUE includes headers, FALSE excludes headers. |
About
Use STOCKHISTORY when you're analyzing stock performance over time, comparing multiple securities, or building investment tracking worksheets. It's faster than manually copying data from financial websites and updates automatically when you reopen your workbook. The function works with daily, weekly, or monthly intervals, and you can choose which data columns to display. For real-time stock quotes, check out the Stocks data type feature in Excel. For currency exchange rates, try WEBSERVICE.
Keep in mind that STOCKHISTORY requires a Microsoft 365 subscription and an internet connection. The data comes from LSEG Data & Analytics and typically updates after each trading day closes, so you won't get live intraday prices.
Examples
Tracking Tesla stock for a quarter
=STOCKHISTORY("TSLA", DATE(2025,1,1), DATE(2025,3,31), 0, 1) Monthly Apple stock performance
=STOCKHISTORY("AAPL", DATE(2024,1,1), DATE(2024,12,31), 2, 1, 0, 1, 2, 3, 4, 5) Year-to-date Microsoft performance
=STOCKHISTORY("MSFT", DATE(2026,1,1), TODAY(), 1, 1) Simple price history without headers
=STOCKHISTORY("NVDA", DATE(2025,10,1), DATE(2025,10,31), 0, 0, 0, 1) Watch out for
Using index funds or ETFs
Many popular index funds like S&P 500 trackers lack historical data in STOCKHISTORY, even though they work with the Stocks data type.
→ Stick to individual company stocks. If you need index data, consider downloading it from financial websites or using constituent stocks instead.
Interval numbers instead of names
Excel expects numeric codes for intervals (0 for daily, 1 for weekly, 2 for monthly), but it's easy to forget which number means which interval.
→ Use 0 for daily data, 1 for weekly, and 2 for monthly. You can't type "daily" or "weekly" as text like in older examples.
Spilled array gets deleted
When you delete a STOCKHISTORY formula, Excel leaves behind the formatted cells from the spilled array, creating ghost data that looks real but won't update.
→ Always clear the entire spilled range after deleting the formula. Look for the blue border around the array to see which cells to clear.
Expecting real-time prices
STOCKHISTORY shows historical data that updates after trading days close, not live prices during market hours.
→ For current prices, use the Stocks data type feature instead. STOCKHISTORY is designed for historical analysis, not real-time trading decisions.