
The STOCKHISTORY function lets you get stock prices based on a stock quote. It is in the Lookup and reference category and is soon available to Excel 365 subscribers.
The image above shows a dynamic array formula in cell B6:
=STOCKHISTORY(C2, C3, C4, 0, 2, 0, 1, 2, 3, 4, 5)
The function uses the stock quote in specified in cell C2, the start date in cell C3, and the end date in cell C4 to get stock prices.
The formula returns an array of values to cells below and to the right of cell C6.
1. STOCKHISTORY Function Syntax

STOCKHISTORY(stock, start_date, [end_date], [interval], [headers], [property0], [property1], [property2], [property3], [property4], [property5])
Back to top
2. STOCKHISTORY Function Arguments

Argument |
Text |
stock |
Required. A stock ticker or a reference to a stock ticker. |
start_date |
Required. The first date to start retrieving stock prices for. |
[end_date] |
Optional. The last date to start retrieving stock prices for. |
[interval] |
Optional. Specify the interval.
0 = daily (default)
1 = weekly
2 = monthly |
[headers] |
Optional. Enable header names.
0 = no headers
1 = show headers (default)
2 = show instrument identifier and headers |
[property0] |
Optional. Which columns to show:
0 = Date
1 = Close
2 = Open
3 = High
4 = Low
5 = Volume |
[property1] |
Optional. See [property0] above. |
[property2] |
Optional. See [property0] above. |
[property3] |
Optional. See [property0] above. |
[property4] |
Optional. See [property0] above. |
[property5] |
Optional. See [property0] above. |
Back to top
3. How to get daily stock prices in Excel

The STOCKHISTORY function retrieves historical stock prices for a given ticker. You can specify the interval meaning daily, weekly or monthly prices.
The image above demonstrates the STOCKHISTORY function in cell B6, it returns in this example historical daily stock prices for Microsoft between 10/14/2021 and 10/28/2021 specified in cells C3 and C4.
Change the ticker and date range in cells C2:C4 and the function automatically returns data based on the new conditions.
The image above shows a dynamic array formula in cell B6:
=STOCKHISTORY(C2, C3, C4, 0, 2, 0, 1, 2, 3, 4, 5)
The formula above returns header names shown in row 7 as well as the ticker in cell B6. Date, Close, Open, High, Low, and Volume data is returned in this example, however, you can choose the order and what to include using the optional arguments in positions six to eleven.
Back to top
4. How to get weekly stock prices

The image above demonstrates how to return weekly stock prices using the STOCKHISTORY function.
The image above shows a dynamic array formula in cell B6:
=STOCKHISTORY(C2, C3, C4, 1, 2, 0, 1, 2, 3, 4, 5)
Back to top
5. How to get monthly stock prices

The formula above demonstrates how to get monthly stock prices.
Dynamic array formula in cell B6:
=STOCKHISTORY(C2, C3, C4, 2, 2, 0, 1, 2, 3, 4, 5)
Back to top
6. How to get daily closing stock prices

The image above shows a dynamic array formula in cell B6:
=STOCKHISTORY(C2, C3, C4, 0, 2, 0, 1)
Back to top
7. How to get volume for a stock quote on a given day

The image above demonstrates a formula returning volume data for a stock ticker specified in cell C2.
Dynamic array formula in cell B6:
=STOCKHISTORY(C2, C3, C4, 0, 2, 0, 5)
Back to top
8. How to calculate a moving average

The image above demonstrates a formula in cell F33 that calculates the average based on the previous 10 days' closing price.
Dynamic array formula in cell B6:
=AVERAGE(C23:C32)
The AVERAGE function calculates the average based on a group of numbers. 10-day, 20 day, 50-day, and 200-day averages are often used to calculate the short trend, medium trend, and long trend direction.
How to plot a moving average on a stock chart
Back to top
9. Get Excel file
Back to top
The following article has a formula that contains the STOCKHISTORY function.
The STOCKHISTORY function function is one of many functions in the 'Lookup and reference' category.
Returns the address of a specific cell, you need to provide a row and column number.
Returns the number of cell ranges and single cells in a reference.
Gets a value based on a number.
Returns the column number of the top-left cell of a cell reference.
Calculates the number of columns in a cell range.
Extracts values/rows based on a condition or criteria.
Returns a formula as a text string.
Searches the top row in a data range for a value and return another value on the same column in a row you specify.
Builds a link in a cell.
Returns a value or reference from a cell range or array, you specify which value based on a row and column number.
Returns the cell reference based on a text string and shows the content of that cell reference.
Find a value in a cell range and return a corresponding value on the same row.
Returns the relative position of an item in an array that matches a specified value in a specific order.
Returns a reference to a range that is a given number of rows and columns from a given reference.
Calculates the row number of a cell reference.
Calculate the number of rows in a cell range.
Sorts values from a cell range or array
Sorts a cell range or array based on values in a corresponding range or array.
Downloads stock prices based on a stock quote
Converts a vertical range to a horizontal range, or vice versa.
Returns a unique or unique distinct list.
Lets you search the leftmost column for a value and return another value on the same row in a column you specify.
Search one column for a given value, and return a corresponding value in another column from the same row.
Searches for an item in an array or cell range and returns the relative position.
Excel functions that let you resize, combine, and shape arrays.
Functions for backward compatibility with earlier Excel versions. Compatibility functions are replaced with newer functions with improved accuracy. Use the new functions if compatibility isn't required.
Perform basic operations to a database-like structure.
Functions that let you perform calculations to Excel date and time values.
Let's you manipulate binary numbers, convert values between different numeral systems, and calculate imaginary numbers.
Calculate present value, interest, accumulated interest, principal, accumulated principal, depreciation, payment, price, growth, yield for securities, and other financial calculations.
Functions that let you get information from a cell, formatting, formula, worksheet, workbook, filepath, and other entitites.
Functions that let you return and manipulate logical values, and also control formula calculations based on logical expressions.
These functions let you sort, lookup, get external data like stock quotes, filter values based a condition or criteria, and get the relative position of a given value in a specific cell range. They also let you calculate row, column, and other properties of cell references.
You will find functions in this category that calculates random values, round numerical values, create sequential numbers, trigonometry, and more.
Calculate distributions, binomial distributions, exponential distribution, probabilities, variance, covariance, confidence interval, frequency, geometric mean, standard deviation, average, median, and other statistical metrics.
Functions that let you manipulate text values, substitute strings, find string in value, extract a substring in a string, convert characters to ANSI code among other functions.
Get data from the internet, extract data from an XML string and more.
Latest updated articles.
More than 300 Excel functions with detailed information including syntax, arguments, return values, and examples for most of the functions used in Excel formulas.
More than 1300 formulas organized in subcategories.
Excel Tables simplifies your work with data, adding or removing data, filtering, totals, sorting, enhance readability using cell formatting, cell references, formulas, and more.
Allows you to filter data based on selected value , a given text, or other criteria. It also lets you filter existing data or move filtered values to a new location.
Lets you control what a user can type into a cell. It allows you to specifiy conditions and show a custom message if entered data is not valid.
Lets the user work more efficiently by showing a list that the user can select a value from. This lets you control what is shown in the list and is faster than typing into a cell.
Lets you name one or more cells, this makes it easier to find cells using the Name box, read and understand formulas containing names instead of cell references.
The Excel Solver is a free add-in that uses objective cells, constraints based on formulas on a worksheet to perform what-if analysis and other decision problems like permutations and combinations.
An Excel feature that lets you visualize data in a graph.
Format cells or cell values based a condition or criteria, there a multiple built-in Conditional Formatting tools you can use or use a custom-made conditional formatting formula.
Lets you quickly summarize vast amounts of data in a very user-friendly way. This powerful Excel feature lets you then analyze, organize and categorize important data efficiently.
VBA stands for Visual Basic for Applications and is a computer programming language developed by Microsoft, it allows you to automate time-consuming tasks and create custom functions.
A program or subroutine built in VBA that anyone can create. Use the macro-recorder to quickly create your own VBA macros.
UDF stands for User Defined Functions and is custom built functions anyone can create.
A list of all published articles.
How to comment
How to add a formula to your comment
<code>Insert your formula here.</code>
Convert less than and larger than signs
Use html character entities instead of less than and larger than signs.
< becomes < and > becomes >
How to add VBA code to your comment
[vb 1="vbnet" language=","]
Put your VBA code here.
[/vb]
How to add a picture to your comment:
Upload picture to postimage.org or imgur
Paste image link to your comment.
Contact Oscar
You can contact me through this contact form