I have a problem wanting to use the variable "name" of another subroutine. I want it to be able to edit a graph. In this case, the first subroutine generates the graph and gives it the name. In the second subroutine, I want to edit it but I can not call the variable "name" which is where I have what the graphic is called.
Public **nombre** As String
Sub GRAFICA2()
Dim Grafica As String
nombre = InputBox("Escribe el nombre de la grafica:")
Dim Rango As Range
Set Rango = Selection
ActiveSheet.Shapes.AddChart2(201, xlColumnClustered).Select
ActiveChart.SetSourceData Source:=Rango
ActiveChart.Parent.Name = nombre
ActiveSheet.ChartObjects(nombre).Activate
ActiveChart.ChartTitle.Select
Selection.Delete
Dim cht As Chart
Set cht = ActiveSheet.ChartObjects(nombre).Chart
cht.ChartArea.Format.TextFrame2.TextRange.Font.Size = 10
cht.ChartArea.Format.TextFrame2.TextRange.Font.Name = "Arial"
cht.ChartArea.Font.Color = RGB(0, 0, 0)
End Sub
Sub grafica2A()
Dim Rango2 As Range
Set Rango2 = Application.InputBox("Select a range", "Obtain Range Object", Type:=8)
ActiveSheet.ChartObjects(nombre).Activate
ActiveChart.Axes(xlValue).MajorGridlines.Select
ActiveChart.FullSeriesCollection(1).XValues = Rango2
End Sub