VBA – Create a Bar Chart
Create Bar Chart in VBA
The following tutorial will describe how to create a bar chart using VBA.
1. Enter the VBA project window by right clicking on a sheet name and selecting “View Code” or by selecting “ALT, F11”.
2. On the right hand side, right click on your project name and select inset “module”.
3. Copy and paste the following code into the new module you just created:
Dim myRange As Range
Set myRange = Application.InputBox _
(Prompt:="Select chart inputs", Type:=8)
ActiveChart.ChartType = xlColumnClustered
ActiveChart.SetSourceData Source:=myRange, _
4. Click on the save button.
5. Click on the little Excel icon on the top right under the “File” menu to exit the VBA project window and to return to Excel.
6. Next run the macro by pressing “Alt F8” to bring up the list of macro’s available and selecting “MakeChart”.
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!
Did you find this VBA tutorial useful? Then share it with your friends and colleagues: