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
The VBA code used to accomplish this:
Dim MyChart As Chart
Dim MyRange As Range
Set MyChart = ActiveSheet.ChartObjects(1).Chart
Set MyRange = Sheet1.Range("B2:D6")
.Left = MyRange.Left
.Top = MyRange.Top
.Width = MyRange.Width
.Height = MyRange.Height
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!
Did you find this VBA tutorial useful? Then share it with your friends and colleagues: