Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.charting
|
|||
|
|||
Chart Variables
I am using Excel 2003. I'm using "Option Explicit" to force variable
declaration. I want to tie the axes of a chart that I have named "MyChart" to worksheet cells. I've been working with the following but continue to get errors: Dim Cht as ChartObject Set Cht = Worksheets("Model").ChartObjects("MyChart").Chart With Cht.Axes(xlValue) .MaximumScale = Sheets("Charts").Range("C7") .MinimumScale = Sheets("Charts").Range("C9") .MajorUnit = Sheets("Charts").Range("C8") End With If I take out the "Option Explicit" I can get things to work. However, I would like to keep it in my code to help make sure I am declaring variables correctly. Can anyone advise as to what I am doing wrong? Thank you in advance for your help. -- Steph |
#2
Posted to microsoft.public.excel.charting
|
|||
|
|||
Chart Variables
Steph a écrit :
Hi To me, Cht is a Chart, not a ChartObject so... Dim Cht As Chart -- François L I am using Excel 2003. I'm using "Option Explicit" to force variable declaration. I want to tie the axes of a chart that I have named "MyChart" to worksheet cells. I've been working with the following but continue to get errors: Dim Cht as ChartObject Set Cht = Worksheets("Model").ChartObjects("MyChart").Chart With Cht.Axes(xlValue) .MaximumScale = Sheets("Charts").Range("C7") .MinimumScale = Sheets("Charts").Range("C9") .MajorUnit = Sheets("Charts").Range("C8") End With If I take out the "Option Explicit" I can get things to work. However, I would like to keep it in my code to help make sure I am declaring variables correctly. Can anyone advise as to what I am doing wrong? Thank you in advance for your help. |
#3
Posted to microsoft.public.excel.charting
|
|||
|
|||
Chart Variables
Hi,
You have declared the object variable Cht as ChartObject but when setting the reference to it you actually drill further down the object model and reference the Chart. Either change the declaration to, Dim Cht As Chart Or the way you set the reference and then use it, Set Cht = Worksheets("Model").ChartObjects("MyChart") With Cht.Chart.Axes(xlValue) Cheers Andy Steph wrote: I am using Excel 2003. I'm using "Option Explicit" to force variable declaration. I want to tie the axes of a chart that I have named "MyChart" to worksheet cells. I've been working with the following but continue to get errors: Dim Cht as ChartObject Set Cht = Worksheets("Model").ChartObjects("MyChart").Chart With Cht.Axes(xlValue) .MaximumScale = Sheets("Charts").Range("C7") .MinimumScale = Sheets("Charts").Range("C9") .MajorUnit = Sheets("Charts").Range("C8") End With If I take out the "Option Explicit" I can get things to work. However, I would like to keep it in my code to help make sure I am declaring variables correctly. Can anyone advise as to what I am doing wrong? Thank you in advance for your help. -- Andy Pope, Microsoft MVP - Excel http://www.andypope.info |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Chart with three variables | Charts and Charting in Excel | |||
referencing a value from a chart with 3 variables | New Users to Excel | |||
Using variables in Chart Ranges | Charts and Charting in Excel | |||
graphing two variables on one chart | Charts and Charting in Excel | |||
Use variables for a chart | Charts and Charting in Excel |