Crear graficos dinamicos desde vba
Hola, estoy intentando crear graficos dinamicos desde vba, he grabado una macro de crear un grafico, si ejecuto la macro grabada sin modificarla me funciona, pero a la que la modifico para hacer que la macro sea dinamica me da error (varios) casi siempre cuando asigno los valores de una serie ( ActiveChart.SeriesCollection(series).Values = " ='Futures Artwork'!R" & cIn & "C5:R" & cFi & "C5" ). Aqui pongo el código de la macro.
Dim cLL
Dim bActual
Dim cIn
Dim cFi
Dim series
Dim lv_primer
lv_primer = 1
series = 1 'Serie actual
cLL = 5 'Fila per la cual comencem a mirar
bActual = hoja1.Range("C" & cLL) 'Això ens marcarà el principi de nova sèrie
cIn = 5 'fila per la que comencem
Do While Not (hoja1.Range("E" & cLL) = "")
If bActual <> hoja1.Range("C" & cLL) Then
cFi = cLL - 1
If lv_primer = 1 Then
Charts.Add
ActiveChart.ChartType = xlColumnClustered
ActiveChart.SetSourceData Source:=Sheets("Futures Artwork").Range("G3"), _
PlotBy:=xlColumns
lv_primer = 0
End If
ActiveChart.SeriesCollection.NewSeries
Valors = " ='Futures Artwork'!R" & cIn & "C5:R" & cFi & "C5"
xValors = " ='Futures Artwork'!R" & cIn & "C1:R" & cFi & "C1"
ActiveChart.SeriesCollection(series).XValues = xValors
ActiveChart.SeriesCollection(series).Values = Valors
ActiveChart.SeriesCollection(series).Name = bActual
bActual = hoja1.Range("C" & cLL)
cIn = cLL
series = series + 1
End If
cLL = cLL + 1
Loop
ActiveChart.Location Where:=xlLocationAsObject, Name:="Futures Artwork"
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = hoja1.Range("A3") & " - Views"
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "Month"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Views"
End With
Muchas gracias de antemano !!
Dim cLL
Dim bActual
Dim cIn
Dim cFi
Dim series
Dim lv_primer
lv_primer = 1
series = 1 'Serie actual
cLL = 5 'Fila per la cual comencem a mirar
bActual = hoja1.Range("C" & cLL) 'Això ens marcarà el principi de nova sèrie
cIn = 5 'fila per la que comencem
Do While Not (hoja1.Range("E" & cLL) = "")
If bActual <> hoja1.Range("C" & cLL) Then
cFi = cLL - 1
If lv_primer = 1 Then
Charts.Add
ActiveChart.ChartType = xlColumnClustered
ActiveChart.SetSourceData Source:=Sheets("Futures Artwork").Range("G3"), _
PlotBy:=xlColumns
lv_primer = 0
End If
ActiveChart.SeriesCollection.NewSeries
Valors = " ='Futures Artwork'!R" & cIn & "C5:R" & cFi & "C5"
xValors = " ='Futures Artwork'!R" & cIn & "C1:R" & cFi & "C1"
ActiveChart.SeriesCollection(series).XValues = xValors
ActiveChart.SeriesCollection(series).Values = Valors
ActiveChart.SeriesCollection(series).Name = bActual
bActual = hoja1.Range("C" & cLL)
cIn = cLL
series = series + 1
End If
cLL = cLL + 1
Loop
ActiveChart.Location Where:=xlLocationAsObject, Name:="Futures Artwork"
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = hoja1.Range("A3") & " - Views"
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "Month"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Views"
End With
Muchas gracias de antemano !!
1 Respuesta
Respuesta de jgirj
1