VBA / Macro / Spilled Array / StockHistory

Copper Contributor

Hi, I'm struggling to get a simple VBA macro to get data from a stockhistory spilled array.  Please see screenshots.  Basically, the stockhistory function runs fine manually outside of a macro.  But if the stockhistory function attempts to pull stock data within a macro, it gets stuck on a #Busy! error indefinitely until the macro is aborted.  As soon as I end the macro run, the spilled array will automatically finish populating without any additional input on my part.  This proves to me that there's nothing wrong with the input.  For some reason, Excel does not want to finish performing this stockhistory function while the macro is still running, or while in debugging/step mode.  I don't know if this is an issue with stockhistory, with spilled arrays, with pulling info from external sources, etc.  I'm hoping there's just a setting or a trick that I don't know about yet. 

Thanks for any help! 

5 Replies

@djk5214 

 

What is it that the macro does that STOCKHISTORY by itself won't do in your situation?

 

I ask as a person who avoids macros unless absolutely necessary (and that condition rarely arises). So you can take my question with a grain of salt if you're a true believe in macros, but please hear me when I say I've often seen the situation where people jump to macros far sooner than they need to. Excel's built-in functions are amazingly powerful.

The macro in the screenshot is just a basic script to show what my issue is. In actuality, I want to test my strategies on a hundred different stocks or so. So instead of me manually performing a stock history lookup on every single stock, I want a macro to automatically run through a list of stocks and collect data from each stockhistory lookup. That way, I just click "run" once and I get my list of data. It would save me a huge amount of time.
And regardless of what I plan to use the macro for, I still would like to understand why this specific function does not want to work within a macro. This could have implications for a wide variety of uses. If the issue is with spilled arrays itself, then stockhistory isn't the only way to create a spilled array, and I'm sure others would like to know how to fix this issue as well.
To djk5214,
your question was asked about a year and a half ago. I am experiencing exactly the same problem. Did you ever get a solution??

Regards cmsleopoldo

@djk5214 

 

your question was asked about a year and a half ago. I am experiencing exactly the same issue. Did you ever get a solution??

Regards

cmsleopoldo