ConCat
New Member
- Joined
- Mar 11, 2023
- Messages
- 4
- Office Version
- 365
- Platform
- Windows
Hi
This is more of an observation through trial and error more than a question.
General formula:
Problem:
With these parameters, the last zero will only return the dates without the Open/Close/High/Low/Volume data. This gives me a "Run-time error '1004': Application-defined or object-defined error"
As I understand the problem, when it tries to return the dates without any other data. It doesn't know which date to "latch on to" as there are no other data.
First I assumed it wouldn't be a problem as it would latch the dates on to simulated data entries corresponding to which Start_Date and End_Date then populate the array with the dates, but I'm not sure if this is a bug, shortcoming or working as intended.
Anyone has some insight about this issue?
I've been helped by this forum countless times over the years. I just now decided to make an account and write a post about something. Small details in a comment, or hidden in a huge wall of text has been the key to many of my solutions. Maybe this can help someone else in the future.
Thanks for reading my first post. Have a nice day!
This is more of an observation through trial and error more than a question.
General formula:
- StockHistory(Ticker, Start_Date, End_Date, Frequency, Header, Property[0-5])
- 0 - Daily
- 1 - Weekly
- 2 - Monthly
- 0 - No Header
- 1 - Header
- 2 - Header + Ticker
- 0 - Date
- 1 - Close
- 2 - Open
- 3 - High
- 4 - Low
- 5 - Volume
VBA Code:
Sub GetStockHistory()
Dim Start_Date As Date: Start_Date = "01/01/2020"
Dim End_Date As Date: End_Date = Date
Dim Array_Date As Variant
Array_Date = WorksheetFunction.StockHistory("MSFT", Start_Date, End_Date, 0, 0, 2, 3, 4, 1, 5, 0) 'Frequency: Daily, Header: None, Properties: Open - High - Low - Close - Volume - Date
End Sub
Problem:
VBA Code:
Array_Date = WorksheetFunction.StockHistory("MSFT", Start_Date, End_Date, 0, 0, 0) 'Frequency: Daily, Header: None, Properties: Date (Only)
With these parameters, the last zero will only return the dates without the Open/Close/High/Low/Volume data. This gives me a "Run-time error '1004': Application-defined or object-defined error"
As I understand the problem, when it tries to return the dates without any other data. It doesn't know which date to "latch on to" as there are no other data.
First I assumed it wouldn't be a problem as it would latch the dates on to simulated data entries corresponding to which Start_Date and End_Date then populate the array with the dates, but I'm not sure if this is a bug, shortcoming or working as intended.
Anyone has some insight about this issue?
I've been helped by this forum countless times over the years. I just now decided to make an account and write a post about something. Small details in a comment, or hidden in a huge wall of text has been the key to many of my solutions. Maybe this can help someone else in the future.
Thanks for reading my first post. Have a nice day!