DEV Community

Andrews
Andrews

Posted on • Originally published at geekexcel.com on

Resize All Charts using Macros (VBA) in Excel Office 365!!

If you have a lot of charts in one worksheet in Excel and you want to organize them, what will you do? You can achieve it with the help of Macros in Excel. VBA and Macros are really easy to understand and perform tasks. In this article, we are going to see how to resize all charts using Macros (VBA) in Excel Office 365. Let’s get into this article.

Instructions to Resize All Charts using Macros:

Follow the below instructions to resize all charts in Excel.

  • In the below screenshot, you can see three charts in one worksheet, and we are going to resize all of them.

Example Charts
Example Charts

  • On the Developer Tab, select the Visual Basic option under the Code section.

Select Visual Basic option
Select the Visual Basic option

  • Then you need to copy and paste the code given below.

VBA code to resize charts using Macros

‘Change the Width and Height values below

Sub ResizeCharts()

Dim counter As Integer

‘Loop through all of the charts

For counter = 1 To ActiveSheet.ChartObjects.Count

With ActiveSheet.ChartObjects(counter)

.Height = 200

.Width = 200

End With

Next counter

End Sub

  • You need to save the code by selecting it. Then close the window.

Save the code
Save the code

  • You have to open the sheet containing the data. On the Developer Tab, choose the Macros option in the Code section.

Choose the Macros option
Choose the Macros option

  • You need to make sure that your macro is selected and click the Run button.

Click the Run button
Click the Run button

  • At last, you will see all the resized charts in your worksheet, and you can organize them as you wish.
  • Refer to the below image.

Output
Output

Summary:

In the above article, we have described the simple instructions to resize all charts using Macros (VBA) in Excel Office 365. Share your suggestions/feedback in the below comment section. Thanks for visiting Geek Excel. Keep Learning!

Keep Reading:

Top comments (0)