how to make fixed chart size

jmckeone

Well-known Member
Joined
Jun 3, 2006
Messages
550
I am trying to make a code that will cause a chart to remain its present size despite changes in columns or rows. Got this from recording a macro but want to change code to a generic format so I can run it on any chart and not just 'Chart19'

Even better would be code that would cycle through all charts on a tab and apply this macro to them as well.

Thanks in advance for any assistance.

Code:
Sub ChartFixSize()
'
' ChartFixSize Macro
' Select chart and then run this macro to make it so that it does not resize when rows or
' columns are changed. 10/10/2006 by Jon
'

'
    With Sheets("Sheet1").DrawingObjects("Chart 19")
        .Placement = xlMove
        .PrintObject = True
    End With
    Sheets("Sheet1").DrawingObjects("Chart 19").Locked = True
End Sub
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
You can iterate through all of the DrawingObjects on a worksheet:
Code:
Sub Lock_Objects()

For Each obj In Sheets("Sheet2").DrawingObjects
    obj.Placement = xlMove
    obj.Locked = True
Next obj

End Sub

-Tim
 
Upvote 0
Is there a way to adjust the code to use the active sheet rather than a named sheet?
 
Upvote 0
Sure.

Code:
Sub Lock_Objects()

For Each obj In ActiveSheet.DrawingObjects
    obj.Placement = xlMove
    obj.Locked = True
Next obj

End Sub
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,685
Members
448,977
Latest member
dbonilla0331

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