DEV Community

Andrews
Andrews

Posted on • Originally published at geekexcel.com on

Change Chart Type using Macros (VBA) in Excel Office 365!!

Generally, charts will make it easier to understand any data or information. Because it shows the information in a creative and attractive way. Excel charts option has many chart types, and they are unique. In this tutorial, we are going to see how to change chart type using Macros (VBA) in Excel Office 365. You just follow the steps given below and convert the type of chart that you have in your Excel worksheet.

Change Chart Type using Macros:

To convert the chart type in Excel, you need to follow the below instructions.

  • The below-given screenshot has shown the example bar chart, and we are going to change it to a Pie chart.

Example chart
Example chart

  • 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 convert Chart type using Macros

‘Select your chart

Sub ApplyPieChart()

‘This is the bar chart, you can change the type

ActiveChart.ChartType = xlPie

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

  • Now, you will see that the selected bar chart has been changed into a Pie chart as shown in the below image.

Output
Output

Summary:

In this tutorial, we guided you to know the steps to change chart type using Macros (VBA) in Excel Office 365. Drop your queries/suggestions in the below comment section. Thanks for visiting Geek Excel. Keep Learning!

Keep Reading:

Top comments (0)