How to Create Chart through VBA in Microsoft Excel
In this article, we are going to learn how to create chart through VBA in Microsoft Excel.
Let’s understand with a simple exercise that how we can create chart through VBA in Microsoft Excel.
We have data in range A1:F10 in which column A contains student’s name, column B Marks 1, column C Marks 2, column D Marks 3, column E contains Total Score, and column F contains Average of Marks.
Follow below given steps and code:-
Private Sub CommandButton1_Click()
ActiveChart.ChartType = xlColumnClustered
Code Explanation:- First, we will define the range of selection to insert the chart then we set the data source and chart type. Before performing an action on the chart, we need to activate it, and then we select the destination where we want to paste our chart, and after that we need to return to sheet 1.
This is the way we can create chart through VBA in Microsoft Excel.
The applications/code on this site are distributed as is and without warranties or liability. In no event shall the owner of the copyrights, or the authors of the applications/code be liable for any loss of profit, any problems or any damage resulting from the use or evaluation of the applications/code.