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:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
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!