terrytibbs101
New Member
- Joined
- Dec 28, 2018
- Messages
- 2
I have created a simple macro to scrape/download share prices from yahoo.
I have created a bog standard candlestick chart and I would like the ability to automatically adjust the y axis scale (price scale) via a macro so that as I download a different stock price the chart automatically adjusts its scale.
The macro I have written is:
Sub chartadj()
'
' chartadj Macro
'
'
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.Axes(xlValue).Select
ActiveChart.Axes(xlValue).MinimumScale = 0
ActiveChart.Axes(xlValue).MinimumScale = Parameters!k7
ActiveChart.Axes(xlValue).MaximumScale = 250
ActiveChart.Axes(xlValue).MaximumScale = Parameters!k6
End Sub
But every time I run the macro I get a runtime arror that states "the item with the specified name wasnt found", when I look at the code the below name is highlighted in yellow:
ActiveSheet.ChartObjects("Chart 1").Activate
Clearly its to do with the selection of the chart, I only have one chart in the whole workbook so cant understand why it wont let me do this.
Any thoughts/comments would be very much appreciated?
I have created a bog standard candlestick chart and I would like the ability to automatically adjust the y axis scale (price scale) via a macro so that as I download a different stock price the chart automatically adjusts its scale.
The macro I have written is:
Sub chartadj()
'
' chartadj Macro
'
'
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.Axes(xlValue).Select
ActiveChart.Axes(xlValue).MinimumScale = 0
ActiveChart.Axes(xlValue).MinimumScale = Parameters!k7
ActiveChart.Axes(xlValue).MaximumScale = 250
ActiveChart.Axes(xlValue).MaximumScale = Parameters!k6
End Sub
But every time I run the macro I get a runtime arror that states "the item with the specified name wasnt found", when I look at the code the below name is highlighted in yellow:
ActiveSheet.ChartObjects("Chart 1").Activate
Clearly its to do with the selection of the chart, I only have one chart in the whole workbook so cant understand why it wont let me do this.
Any thoughts/comments would be very much appreciated?