Hi folks
I've been working on trying to create a loop for adding a graph to a new worksheet for several rows of data and I've got so far with it but hit a brick wall with referencing the correct row and I can't seem to get my head around what is bound to be a simple thing.
This is my code with graph formatting etc removed:
Sub graphs()
'
' graphs Macro
' 13/02/2015
Dim n As Integer
For n = 5 To 100
If Sheets("Data").Cells(n, 1) = 0 Then Exit For
Sheets.Add
ActiveSheet.Move after:=Sheets(ActiveWorkbook.Sheets.Count)
ActiveSheet.Name = Worksheets("data").Cells(n, 1).Value
Charts.Add
ActiveChart.ChartType = xlBarClustered
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection.NewSeries
'Adds static data series:
ActiveChart.SeriesCollection(1).XValues = "=Data!R3C2:R3C3"
ActiveChart.SeriesCollection(1).Values = "=Data!R4C2:R4C3"
ActiveChart.SeriesCollection(1).Name = "=Data!R4C1"
'Adds Individual data series:
ActiveChart.SeriesCollection(2).Values = "=Data!R5C2:R5C3"
ActiveChart.SeriesCollection(2).Name = Sheets("Data").Cells(n, 1)
ActiveChart.Location Where:=xlLocationAsObject, Name:=Worksheets("data").Cells(n, 1).Value
Next n
End Sub
I have got the name of the series(2) data referencing correctly, but I'm unsure how to code the values of this series.
Bookmarks