VBA – Resize an Object to a Range Size

Resize Object to Range Size in VBA

You can size an object like Pictures, Autoshapes, and Charts to be the same size as a Range. To do this, set the objects .Left .Top .Width and .Height properties equal to the respective properties of a Range.

The following example sizes a Chart to the Range B2:D6

size object to range size

The VBA code used to accomplish this:

Sub SizeChart2Range()

Dim MyChart As Chart

Dim MyRange As Range

Set MyChart = ActiveSheet.ChartObjects(1).Chart

Set MyRange = Sheet1.Range("B2:D6")


    With MyChart.Parent

        .Left = MyRange.Left

        .Top = MyRange.Top

        .Width = MyRange.Width

        .Height = MyRange.Height

    End With


End Sub

VBA Coding Made Easy

Stop searching for VBA code online. Learn more about AutoMacro – A VBA Code Builder that allows beginners to code procedures from scratch with minimal coding knowledge and with many time-saving features for all users!

alt text

Learn More!

<<Return to VBA Examples

VBA Code Examples Add-in

Easily access all of the code examples found on our site.

Simply navigate to the menu, click, and the code will be inserted directly into your module. .xlam add-in.

(No installation required!)