Macro para modificar 50 graficos

Hola!
Que macro puedo utilizar para modificar los datos de origen de 50 graficos en excel, si en 1 libro tengo los datos y en los demas libros los graficos, para no hacerlo manualmente 1 x 1. Intente hacerlo con este codigo pero solo me didifica un libro.
ActiveWindow.ScrollWorkbookTabs Position:=xlFirst
Sheets("INGENIERIA DE RED INTELIGENTE").Select
ActiveChart.PlotArea.Select
ActiveChart.SeriesCollection(1).XValues = _
"='P-GRAFICAR_SOLICITANTE'!R59C10:R77C10"
ActiveChart.SeriesCollection(1).Values = _
"='P-GRAFICAR_SOLICITANTE'!R74C16:R77C16"
ActiveChart.SeriesCollection(2).XValues = _
"='P-GRAFICAR_SOLICITANTE'!R74C10:R77C10"
ActiveChart.SeriesCollection(2).Values = _
"='P-GRAFICAR_SOLICITANTE'!R74C15:R77C15"
ActiveChart.SeriesCollection(3).XValues = _
"='P-GRAFICAR_SOLICITANTE'!R74C10:R77C10"
ActiveChart.SeriesCollection(4).Values = _
"='P-GRAFICAR_SOLICITANTE'!R74C11:R77C11"
ActiveChart.SeriesCollection(5).Values = _
"='P-GRAFICAR_SOLICITANTE'!R74C12:R77C12"
ActiveChart.SeriesCollection(6).Values = _
"='P-GRAFICAR_SOLICITANTE'!R74C13:R77C13"
ActiveChart.SeriesCollection(7).Values = _
"='P-GRAFICAR_SOLICITANTE'!R74C14:R77C14"
Espero me puedan ayudar.
Gracias

1 respuesta

Respuesta
1
Si tienes conocimiento en VBA te pongo un ejemplo para que lo adaptes, caso contrario se me hace dificil.
Me parece bien, espero entonces el ejemplo y espero poder adecuarlo.
Gracias
Sub MergeAllWorkbooks()
Dim MyPath As String, FilesInPath As String
Dim MyFiles() As String
Dim SourceRcount As Long, FNum As Long
Dim mybook As Workbook, BaseWks As Worksheet
Dim sourceRange As Range, destrange As Range
Dim rnum As Long, CalcMode As Long
'Fill in the path\folder where the files are
MyPath = "C:\Users\Ron\test"
'Add a slash at the end if the user forget it
If Right(MyPath, 1) <> "\" Then
MyPath = MyPath & "\"
End If
'If there are no Excel files in the folder exit the sub
FilesInPath = Dir(MyPath & "*.xl*")
If FilesInPath = "" Then
MsgBox "No files found"
Exit Sub
End If
'Fill the array(myFiles)with the list of Excel files in the folder
FNum = 0
Do While FilesInPath <> ""
FNum = FNum + 1
ReDim Preserve MyFiles(1 To FNum)
MyFiles(FNum) = FilesInPath
FilesInPath = Dir()
Loop
'Change ScreenUpdating, Calculation and EnableEvents
With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
.EnableEvents = False
End With
'Add a new workbook with one sheet
Set BaseWks = Workbooks.Add(xlWBATWorksheet).Worksheets(1)
rnum = 1
'Loop through all files in the array(myFiles)
If FNum > 0 Then
For FNum = LBound(MyFiles) To UBound(MyFiles)
Set mybook = Nothing
On Error Resume Next
Set mybook = Workbooks.Open(MyPath & MyFiles(FNum))
On Error GoTo 0
If Not mybook Is Nothing Then
On Error Resume Next
With mybook.Worksheets(1)
Tu_Código
GoTo ExitTheSub
Else
'Copy the file name in column A
With sourceRange
BaseWks.Cells(rnum, "A"). _
Resize(.Rows.Count).Value = MyFiles(FNum)
End With
'Set the destrange
Set destrange = BaseWks.Range("B" & rnum)
'we copy the values from the sourceRange to the destrange
With sourceRange
Set destrange = destrange. _
Resize(.Rows.Count, .Columns.Count)
End With
destrange.Value = sourceRange.Value
rnum = rnum + SourceRcount
End If
End If
mybook.Close savechanges:=False
End If
Next FNum
BaseWks.Columns.AutoFit
End If
ExitTheSub:
'Restore ScreenUpdating, Calculation and EnableEvents
With Application
.ScreenUpdating = True
.EnableEvents = True
.Calculation = CalcMode
End With
End Sub
Hasta aquí te puedo ayudar.

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas