![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Mar 2002
Posts: 112
|
I am attempting to use the cobbled code below to determine the current axis of a chart series, and then set a cell value to true of false based on that information. When I execute the code I get a runtime error |Unable to get the ChartObjects property of the worksheet class. Can someone point out the error of my ways?
Regards...Strorg ActiveSheet.ChartObjects("Chart 1").Activate ActiveChart.SeriesCollection(1).Select CurrentAxis = ActiveChart.SeriesCollection(1).AxisGroup Application.Goto Reference:="ap1a" If CurrentAxis = 1 Then ActiveCell.Value = True Else: ActiveCell.Value = False End If |
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Sydney, Australia
Posts: 2,908
|
Hi,
This is probably because the chart isn't called Chart1. The way to check this is to use this code:- Sub GetChartNames() Dim chtObject As ChartObject For Each chtObject In ActiveSheet.ChartObjects MsgBox chtObject.Name Next End Sub Then change your code to the correct ChartObject name. An alternative is to use this instead:- ActiveSheet.ChartObjects(1).Activate This may not work if you have more than one chart on the active sheet. HTH, Dan |
|
|
|
|
|
#3 |
|
Board Regular
Join Date: Mar 2002
Posts: 112
|
Thanks for the tip. My error was too obvious...I wasn't selecting the sheet. DUH. Thanks for the troubleshooting tip with the message box. I'll use it in the future.
Regards...Tom |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|