Excel

Various chart

Ease of Use

Easy

Version tested with

2003 

Submitted by:

laxman

Description:

we can create a various chart for the same data. By using Excel VBA 

Discussion:

 

Code:

instructions for use

			

Option Explicit Private mychart As Chart Private Sub OptionButton1_Click() Set mychart = ActiveSheet.ChartObjects(1).Chart mychart.ChartType = xlArea End Sub Private Sub OptionButton2_Click() Set mychart = ActiveSheet.ChartObjects(1).Chart mychart.ChartType = xlBarClustered End Sub Private Sub OptionButton3_Click() Set mychart = ActiveSheet.ChartObjects(1).Chart mychart.ChartType = xlColumnClustered End Sub Private Sub OptionButton4_Click() Set mychart = ActiveSheet.ChartObjects(1).Chart mychart.ChartType = xlLine End Sub Private Sub OptionButton5_Click() Set mychart = ActiveSheet.ChartObjects(1).Chart mychart.ChartType = xlBubble End Sub Private Sub OptionButton6_Click() Set mychart = ActiveSheet.ChartObjects(1).Chart mychart.ChartType = xlDoughnut End Sub Private Sub OptionButton7_Click() Set mychart = ActiveSheet.ChartObjects(1).Chart mychart.ChartType = xlPie End Sub Private Sub OptionButton8_Click() Set mychart = ActiveSheet.ChartObjects(1).Chart mychart.ChartType = xlRadar End Sub

How to use:

  1. 1.Copy the above code
  2. 2.Press Alt+f11 and paste the code
  3. 3.Save and close the VBA window
  4. 4.Open the excel sheet1
  5. 5.Enter the Data Heading in "A1" Cell
  6. 6.Enter the Datas in A columns
  7. 7.And create Eight Option Button By using the Insert in Developer menu
  8. 8.And insert Chart
  9. 9.In the chart, Right click, select data & select the "A" column data
  10. 10.And click ok
 

Test the code:

  1. 1.select the optionbutton 1 to 8 one by one
  2. 2 See the difference
 

Sample File:

CHART.zip 28.19KB 

Approved by Jacob Hilderbrand


This entry has been viewed 330 times.

Please read our Legal Information and Privacy Policy
Copyright @2004 - 2020 VBA Express