I have VBA code which retrieves historical stock prices data for the last number of periods (days, weeks or months) up to the endDate specified by the user in the workbook.
If I try to download data for more than 100 shares at a time, the speed of download progressively decreases.
The only solution I found is to create several Workbooks with different lists, 100 shares in each one, all of them eventually export (part of downloaded information selected by certain algorithm) to file DataFile.
The inconvenience is that if I want to download price data on a daily basis, I have to manually open each file, change endDate, download data up to this date, close file then open the next one etc.
I’m trying to write macros which would allow me to set endDate in DataFile as a reference for the rest of the workbooks and run all these files one after another by single macros.
Sub GetSecurityHistoricalData runs via Call function:
Call GetSecurityHistoricalData(ThisWorkbook.Worksheets("Control").Range("ControlExtractEndDate").Value, _ dblHistoricalData, dteHistoricalDate, _blnAbort, blnExtractError, blnWarningFound, strURL, _ strResponse, intErrorCount)
When I tried to change:
ThisWorkbook.Worksheets("Control").Range("ControlExtractEndDate").Value,
To
Workbooks(“DataFile.xlsm”).Worksheets(“Control”).Range("ControlExtractEndDate"). Value,
It gives Run-Time error ‘9’
Subscript out of range
I could not find reference to endDate within Sub GetSecurityHistoricalData itself in order to change it to DataFile.
Sorry if description of the problem is confusing, English is not my native language. Would be grateful for suggestions to fix problem.
Thanks in advance.
If I try to download data for more than 100 shares at a time, the speed of download progressively decreases.
The only solution I found is to create several Workbooks with different lists, 100 shares in each one, all of them eventually export (part of downloaded information selected by certain algorithm) to file DataFile.
The inconvenience is that if I want to download price data on a daily basis, I have to manually open each file, change endDate, download data up to this date, close file then open the next one etc.
I’m trying to write macros which would allow me to set endDate in DataFile as a reference for the rest of the workbooks and run all these files one after another by single macros.
Sub GetSecurityHistoricalData runs via Call function:
Call GetSecurityHistoricalData(ThisWorkbook.Worksheets("Control").Range("ControlExtractEndDate").Value, _ dblHistoricalData, dteHistoricalDate, _blnAbort, blnExtractError, blnWarningFound, strURL, _ strResponse, intErrorCount)
When I tried to change:
ThisWorkbook.Worksheets("Control").Range("ControlExtractEndDate").Value,
To
Workbooks(“DataFile.xlsm”).Worksheets(“Control”).Range("ControlExtractEndDate"). Value,
It gives Run-Time error ‘9’
Subscript out of range
I could not find reference to endDate within Sub GetSecurityHistoricalData itself in order to change it to DataFile.
Sorry if description of the problem is confusing, English is not my native language. Would be grateful for suggestions to fix problem.
Thanks in advance.