Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Chart Axes Values 1

Status
Not open for further replies.

clifftech

ISP
Nov 9, 2001
111
US
Is it possible to get a charts maximum and minimum values to show up in designated worksheet cells.

Here is what I have so far for the maximum scale:

Private Sub CommandButton2_Click()

Range("A1") = Worksheets("SARS").ChartObjects("Chart 6").Chart.Axes(xlCategory).MaximumScale.Value


End Sub

The error message says it is missing an object.

What am I leaving out?

(The ultimate goal is to have the axes mim/max values for chart1 on Sheet 1 to be transferred to Chart 2 Sheet 2 when I click the Command button)


 




Hi,

Explicitly reference the sheet...
Code:
Private Sub CommandButton2_Click()

Sheets("Sheet1").Range("A1") = Worksheets("SARS").ChartObjects("Chart 6").Chart.Axes(xlCategory).MaximumScale.Value


End Sub
I often adjust axis max & min scale, using the Worksheet_Activate event. You don't need to write the value to a cell. Just use the value in the chart in Sheet 1.



Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Skip,

This should be easy but it is giving me the error

"Unable to get the ChartObjects property of the Worksheet class".

I'm guessing it cannot find the correct chart but I only have 1 chart on the sheet. How can I be sure I am using the correct Chart name? What other reason could there be for this error?
 
I only have 1 chart on the sheet
Replace this:
ChartObjects("Chart 6")
with this:
ChartObjects(1)

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I tried that but got the error

Unable to get the MaximumScale property of the Axis class.

 




What you are into now is program debuging 101. There are tools that you need to use, to discover what is happening in your code. The Watch Window is one powerful tool. This is the kind of question that you ought to be able to answer yourself.

faq707-4594.

Please describe the chart TYPE that you are using.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Skip,

You're right about needing debugging skills. I was able to get the code to work using the trial and error debugging method which took too long. Here is what I came up with:

Sheets("Sheet1").Range("A1")=ActiveSheet.ChartObjects(1).Chart.Axes(xlValue).MaximumScale

Thanks for the link on debugging and with the help on the code.
 




I wondered why you were using the xlCategory axis, which is why I asked the question regarding the type of chart. Sometimes the category axis has no Min or Max value, when the category type is xlCategoryScale.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top