Hi,
I have made extensive use of the things I have learned here over the last week or so since I found the site. so THANK YOU!
I have a problem that I can't seem to get all the answers for though.
I have a worksheet that is based upon a single macro. The macro populates a base data sheet with data from a report. It then splits the data based upon a couple of criteria into a number of other sheets. (Each sheet is identical in terms of columns and content, with the exception that the data itself is based upon the criteria differences).
Everything up to here is fine and so I havent included it in the attachments.
THe macro then graphs the content of each of these sheets.
The trick comes because I want to define an unknown number of series for each chart based upon the content of one column. The data is already sorted and so I can do an
"if content of cell is not teh same as current series name then it is the start of the new series."
This can give me a seriesname and also I can set an rStart and rEnd for use in the XValues and Values.
BUT!
I am having a real problem trying to get the format right for the series.
My code looks like this:
Function Graph_Portfolio(runname As String) ' Graph_Portfolio Macro ' Macro recorded 23/06/2005 by mhouston Dim r, rw, x, Index As Integer Dim XValuesRange As Range Dim ValueRange As Range Dim ShSource As Worksheet Set ShSource = ActiveSheet Dim SeriesName As String Dim rstart(), rend() Sheets(runname).Select gr = ActiveSheet.UsedRange.Rows.Count 'MyRange = ( ' Clean up the table prior to graphing it r = ActiveSheet.UsedRange.Rows.Count ' Strip out up to 4 blank non-data rows from the table and ensure that rowcount is updated.. For x = 1 To 4 r = ActiveSheet.UsedRange.Rows.Count For rw = 3 To r If ActiveSheet.Cells(rw, "G").Value = "" Then ActiveSheet.Rows(rw).EntireRow.Delete End If Next rw Next x Charts.Add ActiveChart.ChartType = xlLineMarkers ActiveChart.SetSourceData Source:=ShSource.Range("D6"), PlotBy:= _ xlRows Index = 0 SeriesName = "None" 'r = ActiveSheet.UsedRange.Rows.Count For rw = 3 To r Sheets(runname).Select If SeriesName <> "None" Then If ActiveSheet.Cells(rw, "G").Value <> SeriesName Then ActiveChart.Select ActiveChart.SeriesCollection.NewSeries ActiveChart.SeriesCollection(Index).Name = SeriesName XValueRange = (Range("E" & rstart & ":E" & rend)) ValueRange = (Range("G" & rstart & ":G" & rend)) ActiveChart.SeriesCollection(Index).XValues = " & ShSource.Name & .Range(XValueRange)" ActiveChart.SeriesCollection(Index).Values = " & ShSource.Name & .Range(ValueRange)" Index = Index + 1 rstart = Array(rw) Else rend(Index) = rw End If End If Next rw ActiveChart.Location Where:=xlLocationAsNewSheet ' Name the chart chartname = runname + " PCE Chart" ActiveChart.Name = chartname With ActiveChart .HasTitle = True .ChartTitle.Characters.Text = "BR " & runname & " - PCE Chart" .Axes(xlCategory, xlPrimary).HasTitle = True .Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "Method_Paths" .Axes(xlValue, xlPrimary).HasTitle = True .Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "PCE" End With End Function
I have included a sample of one of these generated sheets.
I want to create a chart of "PCE" for "Bucket" for each series based upon "Series"
Any help would be awesome!