How to Use a Named Cell in the Excel STOCKHISTORY Function
Question details
The user wants to replace a hard-coded DATE function within an Excel STOCKHISTORY formula with a named cell to allow for dynamic and easy end-date updates.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Building a dynamic financial tracker or stock model where the historical date range needs to be updated frequently without editing the formula manually.
- Observed behavior
- The formula requires the end date to reference a defined named range instead of a static DATE function.
Ensure that the cell you intend to use as your named range is formatted as a valid Excel date (e.g., MM/DD/YYYY) so the STOCKHISTORY function can process it properly.
Replace the Hard-Coded Date with a Named Range
Modify your STOCKHISTORY formula to point directly to a defined named cell instead of using a static DATE function.
By replacing the static DATE function with a named range, you can quickly change the start or end date of your stock data directly from a worksheet cell, making your financial models much more flexible.
Select the cell that contains your desired end date. Click into the Name Box located to the left of the formula bar, type 'End_Date' (or your preferred name), and press Enter.
Navigate to the cell containing your stock data formula. Replace the hard-coded date argument with your new named range. For example: =STOCKHISTORY("SCHF", DATE(2022,1,1), End_Date, 0, 0, 1)
Press Enter to execute the formula. The STOCKHISTORY function will now dynamically pull data up to the date specified in your 'End_Date' cell.

Looking for a Lightweight Excel Alternative?
While STOCKHISTORY is a proprietary Microsoft 365 connected feature, WPS Spreadsheet is a powerful, free alternative that excels at advanced financial modeling, dynamic named ranges, and standard data analysis.
- 1. Download and Install: Get WPS Office for free and install it across your Windows, Mac, or Linux devices in minutes.
- 2. Open Existing Spreadsheets: Open your standard .xlsx files directly in WPS Spreadsheet without losing your formatting or standard formulas.
- 3. Manage Data Easily: Use the built-in Name Manager to assign dynamic cell references and build robust tracking sheets.

Frequently Asked Questions
Why does my STOCKHISTORY formula return a #VALUE! error when using a named cell?
This error typically occurs if the named cell contains text instead of a valid Excel serial date, or if the named range is misspelled within your formula.
Can I use a named cell for the start date in the STOCKHISTORY function?
Yes, you can replace both the start date and end date arguments with named ranges. This makes your entire historical date range fully dynamic.
How do I edit or delete a named range in Excel?
Navigate to the Formulas tab on the ribbon and click 'Name Manager'. From the dialog box, you can select your named range to modify its reference or delete it entirely.
Will STOCKHISTORY automatically update to today's date?
STOCKHISTORY pulls historical data based on the dates provided. If you want it to always pull up to the current day, you can enter the formula =TODAY() inside your named cell.




