To move a chart to a specific cell or resize to be same as range:
Sub relocate()
Call move_chart_to_cell(Cells(1, 1))
Call resize_chart_same_as_range(Range("A1:E20"))
Call resize_chart_same_as_range(Range("A1:E20"))
End Sub
Sub move_chart_to_cell(cell as range)
ActiveSheet.Shapes("MyChart").Left = cell.Left
ActiveSheet.Shapes("MyChart").Top = cell.Top
ActiveSheet.Shapes("MyChart").Top = cell.Top
End Sub
Sub resize_chart_same_as_range(r as range)
ActiveSheet.Shapes("MyChart").Height = r.Height
ActiveSheet.Shapes("MyChart").Width = r.Width
Sub resize_chart_same_as_range(r as range)
ActiveSheet.Shapes("MyChart").Height = r.Height
ActiveSheet.Shapes("MyChart").Width = r.Width
End Sub
Before Macro run:
After Macro run:
Created by DoMyExcel.com © | Excel & VBA Consulting | Customized Excel Solutions starting at 29 USD
No comments:
Post a Comment