Need to specify chart for rescaling as opposed to All charts in worksheet.

pbinvestor

New Member
Joined
Apr 14, 2002
Messages
19
I use the following routine to scale a chart the way I want to display it
The routine that I "borrowed" however operates on all chart objects in the worksheet.
How do I change the code to only operate on "Chart 6" but leave other charts untouched.

Thanks in advance.

Sub Format_charts()
Dim objCht As ChartObject
For Each objCht In ActiveSheet.ChartObjects
With objCht.Chart
With .Axes(xlValue)
.MaximumScale = ActiveSheet.Range("v18").Value
.MinimumScale = ActiveSheet.Range("u18").Value
' .MajorUnit = ActiveSheet.Range("Unit").Value
End With
End With
Next objCht
End Sub
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
How elegant (and obvious now that you showed me how!)
Thanks so much.

I tried to do the same thing with the y axis using "u1005" and "v1005" as the category variables but got runtime error 13 "type mismatch"

With ActiveSheet.ChartObjects("Chart 6").Chart.Axes(xlCategory)
.MaximumScale = ActiveSheet.Range("U1005").Value
.MinimumScale = ActiveSheet.Range("V1005").Value

End With
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,183
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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