# STOCKHISTORY() function is not returning a consistent number of rows for all stocks.

#### Mr. Snrub

##### Board Regular
I have a spreadsheet with the first column as a Date field and the rest of the columns are ticker symbols for different stocks, like so:

Date:
Code:
``=INDEX(STOCKHISTORY("AAPL", "12/31/2015", "09/06/2021",0,0),,1)``

AAPL:
Code:
``=STOCKHISTORY("AAPL", "12/31/2015", "09/06/2021",0,0,1)``

PINS:
Code:
``=STOCKHISTORY("PINS", "12/31/2015", "09/06/2021",0,0,1)``

ROKU:
Code:
``=STOCKHISTORY("ROKU", "12/31/2015", "09/06/2021",0,0,1)``

The problem is that the STOCKHISTORY() function is not returning a consistent number of rows for each stock. AAPL returns all expected rows, but ROKU only returns 991 rows (it IPO'ed in 9/28/2017). The PINS formula only returns 601 rows, since it IPO'ed in 4/18/2019. So for example the very first row that I'm seeing looks like this:

 Date AAPL PINS ROKU 12/31/2015 26.32 24.40 23.50

The PINS and ROKU values are completely incorrect, since they reflect the stock price on their IPO dates instead of 12/31/2015. Is there any way to ensure that all formulas will return the same number of rows so I don't have to also return the DATE field for every single stock? For all dates that don't have data, I'd be fine with just an NA() error for all dates before the IPO date.

### Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},\$Z\$1:\$Z\$99,\$Y\$1:\$Y\$99),2,False) to lookup Y values to left of Z values.

#### Oaktree

##### MrExcel MVP
I think you've sort of answered your own question as to why it's dangerous to pull values without their corresponding dates. It's much safer to pull the date/value pairs for each ticker, then use a flurry of VLOOKUPs (or similar) to create your consolidated table with all tickers' values.

Replies
1
Views
204
Replies
4
Views
124
Replies
11
Views
552
Replies
3
Views
3K
Replies
9
Views
630

Understanding data is crucial, and the easiest place to start is with Microsoft Excel.

1,151,492
Messages
5,764,686
Members
425,230
Latest member
DzOus

### We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.

### Which adblocker are you using?

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

### Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

### Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back