Dynamic Chart Value

N8theGreat

New Member
Joined
Jan 18, 2011
Messages
38
I have a script in a module which defines the data in the chart as well as the X and Y axis.
In the module:
Code:
Sheets(she).Cells(14, 20) = Int(tn - 10)
In the sheet I have the following script:
Private Sub Worksheet_Change(ByVal Target As Range)
Code:
Select Case Target.Address
    
    Case "$T$12"
        ActiveSheet.ChartObjects("Chart 2").Chart.Axes(xlCategory).MaximumScale = Target.Value
        ActiveSheet.ChartObjects("Chart 1").Chart.Axes(xlCategory).MaximumScale = Target.Value
        ActiveSheet.ChartObjects("Chart 3").Chart.Axes(xlCategory).MaximumScale = Target.Value
End Select
End Sub

When the module script runs and changes the value of "T20", the worksheet script runs and errors with Runtime error '-2147024809 (80070057)' "The item with the specified name wasn't found."
Why am I getting this error?
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Is there a method of ensuring the script in the worksheet will not run until the module script has completed?

I realize Cells(14,20) and T12 are not the same location. There are many updates happening on the page, I chose two that did not match location.
 
Upvote 0
Is there a wait until function that could be used to ensure the module script completes before the worksheet case & target.value script tries to update?
 
Upvote 0
So you're getting an error, good to know. Also good to know would be which line is highlighted in the debugger when the error message pops up.
 
Upvote 0
It errors on line:
Code:
ActiveSheet.ChartObjects("Chart 2").Chart.Axes(xlCategory).MaximumScale = Target.Value
The code in the module writes the value I want as Min. and Max. x-axis values, and the worksheet code (case .... target) immediately runs and errors on the line above. The module code is not complete when the case tries to update the chart value.
 
Last edited:
Upvote 0
So what items in that line could possible not be found?

ActiveSheet... Probably not

ChartObjects("Chart 2")... maybe, but I'd expect a "Subscript out of Range" error instead, if there's no chart object named "Chart 2". But check the chart object names.

Axes(xlCategory)... same as previous, and make sure the axis actually exists.

MaximumScale... What kind of chart is it? If it isn't an XY Scatter chart, then the category axis has no MaximumScale property.
 
Upvote 0

Forum statistics

Threads
1,215,923
Messages
6,127,721
Members
449,399
Latest member
VEVE4014

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.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

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

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

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
Back
Top