STOCKHISTORY: Get Historical Stock Prices & Market Data in Excel

STOCKHISTORY function in Excel tutorial showing historical stock prices trading dates market data and financial analysis
Learn how to use Excel’s STOCKHISTORY function to retrieve historical stock market data directly into a spreadsheet. This tutorial explains the function syntax, stock and date inputs, interval settings, and how to return historical prices, opening and closing values, highs, lows, and trading volume. You’ll also learn how to build dynamic stock analysis tables and use STOCKHISTORY for investment research, financial reporting, portfolio analysis, and market tracking. Ideal for investors, finance professionals, analysts, students, and Excel users working with historical market data.

You want to chart a stock over the last year, or pull a month of closing prices into a model. In the past, that meant hunting on a finance website, copying a table, and pasting it in, then repeating the chore every update. Excel now does it with a single formula. The STOCKHISTORY function fetches historical price data for a stock, currency pair, or index, and spills it straight into your sheet. You give it a ticker and a date range, and it returns a dated table of prices that refreshes on demand.

This guide shows how to use STOCKHISTORY well, including its many optional settings. First, it covers the arguments and the important requirements. Then it walks through building price tables, choosing columns, and charting the result. Seven worked examples and a full troubleshooting section follow. By the end, you will pull live market history into a spreadsheet in seconds.

What STOCKHISTORY Does

STOCKHISTORY returns past prices as a spilled array. You write one formula in a single cell. The results fill the cells below and beside it automatically. The infographic below shows this behaviour.

One formula spills a whole history of prices DateClose2024-01-02185.642024-01-03184.252024-01-04181.912024-01-05181.18 the result spills down automatically chart the spilled data =STOCKHISTORY("MSFT", start, end, interval, headers, properties...)

Because the output is a dynamic array, it grows to fit the data. A longer date range simply spills further down the sheet. However, the feature needs a Microsoft 365 subscription with the linked data types. Consequently, it is not available in older, standalone Excel versions. This is the single biggest thing to check before using it.

The Requirements

STOCKHISTORY is a modern, connected feature. It depends on a live data service online. A few conditions must be met before it works. These are all worth checking first.

Before you start: 1. You need Microsoft 365 (a subscription version of Excel). 2. The Stocks linked data type must be available in your region and language. 3. An internet connection is required to fetch the data. 4. The result spills, so leave empty cells below and right. If these hold, the function pulls data from the same service behind the Stocks data type.

The Syntax and Its Many Options

STOCKHISTORY has two required arguments and several optional ones. The first two are the ticker and the start date. The rest fine-tune the output. You add only the ones you need.

Syntax: =STOCKHISTORY(stock, start_date, [end_date], [interval], [headers], [property0], [property1], ...) stock -> the ticker, like "MSFT" or "USD/EUR". start_date -> the first date to fetch. end_date -> optional. Defaults to the start date. interval -> 0 daily, 1 weekly, 2 monthly. headers -> 0 none, 1 show, 2 show with instrument. property0.. -> which columns: 0 Date, 1 Close, 2 Open, 3 High, 4 Low, 5 Volume.
Only the first two are required. A bare =STOCKHISTORY("MSFT", "1/1/2024") works. Everything after that simply shapes the interval, headers, and which price columns appear. Omit an option to accept its default.

Example 1: A Basic Price History

Start with the simplest useful call. You give a ticker and a date range. STOCKHISTORY returns dates and closing prices. The table spills down on its own.

Dates and closing prices: =STOCKHISTORY("MSFT", "1/1/2024", "1/31/2024") Result: a two-column table spilling down, with a Date column and a Close column for each trading day in January. By default the interval is daily and headers are shown, so you get a clean, labelled table with no extra settings.

Example 2: Choose a Weekly or Monthly Interval

Daily data can be too detailed for some needs. The interval argument thins it out. You pass 1 for weekly or 2 for monthly. This suits longer-term trend views nicely. It also keeps a multi-year table manageable.

Weekly and monthly data: Weekly closes for a year: =STOCKHISTORY("MSFT", "1/1/2024", "12/31/2024", 1) Monthly closes for a year: =STOCKHISTORY("MSFT", "1/1/2024", "12/31/2024", 2) The fourth argument sets the interval: 0 is daily, 1 is weekly, and 2 is monthly. Fewer rows spill for wider intervals, which keeps a long history compact.

Example 3: Pick Specific Columns

You often want more than the close alone. The property arguments choose columns. Each number maps to a data field. You list them in the order you want them. The output columns follow that exact sequence.

Select Date, Open, High, Low, Close: =STOCKHISTORY("MSFT", "1/1/2024", "1/31/2024", 0, 1, 0, 2, 3, 4, 1) The trailing numbers pick the columns: 0 = Date, 2 = Open, 3 = High, 4 = Low, 1 = Close This produces a classic OHLC table, ideal for a candlestick-style analysis of the daily price ranges.

Example 4: Control the Headers

Headers are helpful, but not always wanted. The headers argument controls them fully. You choose none, a simple row, or a labelled one. This matters most when feeding another formula. A stray text header can break a calculation.

Turn headers on or off: No header row (raw data only): =STOCKHISTORY("MSFT", "1/1/2024", "1/31/2024", 0, 0) Header row with the instrument name: =STOCKHISTORY("MSFT", "1/1/2024", "1/31/2024", 0, 2) Use 0 when another formula reads the spill, so no text header interferes. Use 1 or 2 for a table people read.

Example 5: Reference the Spilled Result

The spilled array is easy to reuse elsewhere. You point at it with the spill operator. A hash sign after the top cell means the whole range. This keeps later formulas in perfect sync. They never drift out of date.

Work with the whole spill: Say the formula sits in cell E2 and spills down. Average of every closing price it returned: =AVERAGE(F2#) (the # refers to the entire spilled Close column) Highest close in the range: =MAX(F2#) As the history grows or shrinks, these summaries update automatically, with no need to adjust ranges.

Example 6: Analyse the Data

A price history invites quick analysis at once. You can summarise the spilled prices directly. Common measures need only one formula each. The table below shows a few of them.

Measure
Formula on the spill
Average close
=AVERAGE(F2#)
Highest close
=MAX(F2#)
Lowest close
=MIN(F2#)

Each measure reads the spilled Close column by its spill reference. The results refresh whenever the data does. This turns a raw history into a live summary panel. You get a dashboard that maintains itself. No manual copying is ever required again.

Example 7: Guard a Missing Data Case

Sometimes a ticker or date returns nothing. A short guard handles that gracefully. You wrap the call to catch the error. This keeps a dashboard from breaking.

A guarded STOCKHISTORY: =IFERROR( STOCKHISTORY(ticker, start_date, end_date), "No data found. Check the ticker and dates.") How it behaves: Bad ticker or empty range -> a clear message. Valid request -> the price table. This is friendlier than a bare error in a shared workbook, and it tells the user what to fix.

Troubleshooting STOCKHISTORY

All three problems below are the most common. Each has a clear cause and a quick fix.

The function name is not recognised

If Excel does not recognise STOCKHISTORY, your version likely does not support it. The function requires Microsoft 365, the subscription edition, and is not present in one-time-purchase versions like Excel 2019 or 2021. It also depends on the Stocks linked data type, which is only available in certain regions and languages. Check that you are running a current Microsoft 365 build and that linked data types are enabled for your account. If your edition or region does not support the feature, the function simply will not be available.

You get a #SPILL! error

This error means the result cannot spill into the cells it needs. STOCKHISTORY returns a whole table, so it requires empty space below and to the right of the formula cell. If any of those cells already contain data, the spill is blocked and you see #SPILL!. Clear the cells in the path of the output, or move the formula to an open area of the sheet. Once there is enough empty room for the full table to expand, the data spills correctly and the error disappears.

You get a #VALUE! or #BUSY error

If the function returns an error rather than data, check the ticker and the dates first. An unknown symbol, or a date range with no trading days, can return no data. Make sure the ticker is valid and, where needed, includes an exchange prefix. A temporary #BUSY or connection error can also appear while the service fetches data, especially with a slow connection. Wait a moment and let it retry, and confirm you are online. With a valid symbol, a sensible date range, and a working connection, the table returns as expected.

Frequently Asked Questions

  • What does the STOCKHISTORY function do?+
    Essentially, STOCKHISTORY fetches historical price data for a stock, index, or currency pair and spills it into your worksheet as a dated table. You provide a ticker symbol and a start date, and optionally an end date, an interval, header settings, and which price columns to include. For example, =STOCKHISTORY("MSFT", "1/1/2024", "1/31/2024") returns dates and closing prices for that month. The output is a dynamic array that grows to fit the data and refreshes on demand. It replaces the old chore of copying tables from finance websites, and it requires a Microsoft 365 subscription with the Stocks linked data type available.
  • Which columns can STOCKHISTORY return?+
    Specifically, you choose the columns using the property arguments at the end of the formula, each mapped to a number: 0 for Date, 1 for Close, 2 for Open, 3 for High, 4 for Low, and 5 for Volume. You list them in the order you want them to appear, so 0, 2, 3, 4, 1 produces a Date, Open, High, Low, Close table. If you omit the properties, the function defaults to Date and Close, which suits most simple charts. Selecting Open, High, Low, and Close together gives you a full OHLC dataset, which is exactly what you need for candlestick charts and detailed range analysis.
  • Why do I get a #SPILL! error?+
    Because STOCKHISTORY returns an entire table as a dynamic array, it needs empty cells below and to the right of the formula to spill into. A #SPILL! error means something is blocking that path, usually existing data or formatting in the cells the output would occupy. To fix it, clear the cells in the way, or move the formula to an open part of the sheet with plenty of room. Remember that a longer date range or more columns needs more space. Once there is enough empty room for the full result to expand freely, the table spills correctly and the error goes away.
  • Why is STOCKHISTORY missing from my Excel?+
    Notably, STOCKHISTORY is only available in Microsoft 365, the subscription version of Excel, and not in one-time-purchase editions such as Excel 2019 or 2021. It also relies on the Stocks linked data type, which Microsoft provides only in certain regions and languages, so availability varies by account. If the function is missing, first confirm you have a current Microsoft 365 subscription and that your app is fully updated. Then check that linked data types are enabled and supported for your region. If your edition or location does not offer the feature, the function will not appear, and you would need a supported Microsoft 365 setup to use it.