Esta es la forma en que se muestran los datos de lo que habla la línea 4.
La línea 5 habla de que si la grafica queda en la misma hoja o simplemente toma una hoja para ella, por ejemplo:
ActiveChart.Location Where:=xlLocationAsNewSheet, Name:="Grafico 1"
Esta línea indica que la grafica tenga su propia hoja y que su nombre sea Grafico 1.
En este ejemplo ejecuto un código con cada una de las características explicadas en las 5 líneas.
Range("A5:B10").Select
Charts.Add
ActiveChart.ChartType = xlColumnClustered
ActiveChart.SetSourceData Source:=Sheets("Hoja1").Range("A5:B10"), PlotBy:= _xlColumns
ActiveChart.Location Where:=xlLocationAsObject, Name:="Hoja1"
ActiveChart.ChartType = xlPyramidColClustered
ActiveChart.SetSourceData Source:=Sheets("Hoja1").Range("A5:B10"), PlotBy:= xlColumns
ActiveChart.Location Where:=xlLocationAsNewSheet, Name:="Grafico 1"
3. Tipo de Grafico
4. Comose acomodan los datos
5. Como se muestra la grafica, en este caso en una sola hoja
Elabora el siguiente formulario con el siguiente código, para observar los diferentes tipos de gráficos y la forma en que se acomodan los datos:
Dibuja dos Listbox y un Botón y pega el código dentro del formulario.
Private Sub CommandButton1_Click()
Rem este código genera la Grafica en la hoja1
Range("A5:B10").Select
Charts.Add
ActiveChart.ChartType = xlColumnClustered
ActiveChart.SetSourceData Source:=Sheets("Hoja1").Range("A5:B10"), PlotBy:= _
xlColumns
ActiveChart.Location Where:=xlLocationAsObject, Name:="Hoja1"
Rem agrega los diferentes tipos de grafica al Listbox1
ListBox1.AddItem "xlColumnClustered"
ListBox1.AddItem "xlBarClustered"
ListBox1.AddItem "xlLineMarkers"
ListBox1.AddItem "xlPie"
ListBox1.AddItem "xlXYScatter"
ListBox1.AddItem "xlAreaStacked"
ListBox1.AddItem "xlDoughnut"
ListBox1.AddItem "xlRadarMarkers"
ListBox1.AddItem "xlCylinderColClustered"
ListBox1.AddItem "xlConeColClustered"
ListBox1.AddItem "xlPyramidColClustered"
Rem agrega las diferentes formas de acomodar los datos al Listbox2
ListBox2.AddItem "Renglon"
ListBox2.AddItem "Columna"
End Sub
Private Sub ListBox1_Click()
Rem este código da el tipo de grafica al dar clic en el Listbox1
If ListBox1 = "xlColumnClustered" Then ActiveChart.ChartType = xlColumnClustered
If ListBox1 = "xlBarClustered" Then ActiveChart.ChartType = xlBarClustered
If ListBox1 = "xlLineMarkers" Then ActiveChart.ChartType = xlLineMarkers
If ListBox1 = "xlPie" Then ActiveChart.ChartType = xlPie
If ListBox1 = "xlXYScatter" Then ActiveChart.ChartType = xlXYScatter
If ListBox1 = "xlAreaStacked" Then ActiveChart.ChartType = xlAreaStacked
If ListBox1 = "xlDoughnut" Then ActiveChart.ChartType = xlDoughnut
If ListBox1 = "xlRadarMarkers" Then ActiveChart.ChartType = xlRadarMarkers
If ListBox1 = "xlCylinderColClustered" Then ActiveChart.ChartType = xlCylinderColClustered
If ListBox1 = "xlConeColClustered" Then ActiveChart.ChartType = xlConeColClustered
If ListBox1 = "xlPyramidColClustered" Then ActiveChart.ChartType = xlPyramidColClustered
End Sub
Private Sub ListBox2_Click()
If ListBox2 = "Renglon" Then
ActiveChart.SetSourceData Source:=Sheets("Hoja1").Range("A5:B10"), PlotBy:= _
xlRows
End If
If ListBox2 = "Columna" Then
ActiveChart.SetSourceData Source:=Sheets("Hoja1").Range("A5:B10"), PlotBy:= _
xlColumns
End If
End Sub
Antes de ejecutar esta Macro llenas los datos anteriores en la hoja1 de Excel
1. Compartir información en Word 2003. Macros y entorno personalizado En este último curso de Word 2003 , vamos a ver la forma que tiene Word de... [23/11/10] |
860 | ||||
2. Presentaciones con Power Point El programa más empleado en el mundo para realizar presentaciones comerciales, el... [19/11/01] |
229.017 | ||||
3. Introducción al Access Hoy en día cualquier empresa, organización u asociación se enfrenta al manejo de... [03/12/01] |
232.435 |