Hi!
I have a Workbook containing several worksheets and would like to loop through all sheets and make a graph of them.
The workbook is updated every period of time and the contents may vary for each period (different names for the worksheets and different amount of sheets every new period)
I have recorded a macro to build one chart, but I would need to make a loop through all worksheets and build one chart for each sheet.
Where there is "SA_AR_PD" in the code I'd like to get each worksheet name instead:
I have a Workbook containing several worksheets and would like to loop through all sheets and make a graph of them.
The workbook is updated every period of time and the contents may vary for each period (different names for the worksheets and different amount of sheets every new period)
I have recorded a macro to build one chart, but I would need to make a loop through all worksheets and build one chart for each sheet.
Where there is "SA_AR_PD" in the code I'd like to get each worksheet name instead:
Code:
Sub SAgraph()
Range("D1:I14").Select
Charts.Add
ActiveChart.ChartType = xlLineMarkers
ActiveChart.SetSourceData Source:=Sheets("SA_AR_PD").Range("D1:I14"), PlotBy _
:=xlColumns
ActiveChart.Location Where:=xlLocationAsNewSheet, Name:="SA_AR_PD_GR"
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "SERVICE LEVEL " & Sheets("SA_AR_PD").Range("A2")
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "Month"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "%"
End With
ActiveChart.HasLegend = False
ActiveChart.HasDataTable = True
ActiveChart.DataTable.ShowLegendKey = True
End Sub