Cambios en macro de gráficos Excel VBA
Para Elsa. Por cambios realizados en la hoja solicito ayuda con la macro.
Sub graficandoSeries()
'x Elsamatilde
Application.ScreenUpdating = False
Application.EnableEvents = False
Application.Calculation = xlCalculationManual
Range("J11").Select
ActiveSheet.Shapes.AddChart2(240, xlXYScatterSmooth).Select
Application.CutCopyMode = False
'se establece cuál será la ultima serie
x = 1
If Range("B5") <> "" Then x = Range("A5").End(xlToRight).Column
'se agregan las series al gráfico
For i = 2 To x
'se arman los rangos para asignarlos a cada serie
If Cells(6, i) <> "" Then
ini = 6
Else
ini = Cells(6, i).End(xlDown).Row
End If
'se establece la última fila de datos según col i
y = Cells(ini, i).End(xlDown).Row
rgoy = Range(Cells(ini, i), Cells(y, i)).Address ' $B$4:$B$20
rgox = Range(Cells(ini, 1), Cells(y, 1)).Address ' $A$4:$A$20
'se crea la serie
ActiveChart.SeriesCollection.NewSeries
ActiveChart.FullSeriesCollection(i - 1).Name = "=Blad2!" & Cells(6, i).Address
ActiveChart.FullSeriesCollection(i - 1).XValues = "=Blad2!" & rgoy '$B$4:$B$20
ActiveChart.FullSeriesCollection(i - 1).Values = "=Blad2!" & rgox '$A$4:$A$20
'las sgtes series se establecen en eje secundario
If i > 2 Then ActiveChart.FullSeriesCollection(i - 1).AxisGroup = 2
Next i
'ubicación de leyeda y configuración de ejes
ActiveChart.SetElement (msoElementLegendBottom)
ActiveChart.SetElement (msoElementSecondaryValueAxisNone)
Range("J7").Select
Application.ScreenUpdating = True
Application.EnableEvents = True
Application.Calculation = xlCalculationAutomatic
MsgBox "Fin del proceso.", , "Información"
End Sub
Respuesta de Elsa Matilde
2