I have a Macro for making graph which I took from some big Macro code...It is not working on my excel file ...please help me to modify it so that it can work..I have attached the excel file on which i want it to run.
It should make graph of all sheets except first sheet.
Code is :
Dim chartCell As Range
Set chartCell = ws.Cells(StartRow, Col + 3)
Dim xRange As Range
Set xRange = ws.Range(ws.Cells(StartRow, 1), ws.Cells(StartRow + ShortenedIntervalLength - 1, 1))
'insert Chart
With ws.ChartObjects.Add(Left:=chartCell.Left, Top:=chartCell.Top, Width:=800, Height:=1000).Chart
.ChartStyle = 4
For Col = 2 To ColCount
With .SeriesCollection.NewSeries
.ChartType = xlXYScatterSmoothNoMarkers
.XValues = xRange
.Values = ws.Range(ws.Cells(StartRow, Col), ws.Cells(StartRow + ShortenedIntervalLength - 1, Col))
.Name = ws.Cells(StartRow - 1, Col).Value
End With
Next
With .SeriesCollection.NewSeries
.ChartType = xlXYScatterSmoothNoMarkers
.XValues = xRange
.Values = avgRange
.Name = "Mittelwert"
.Border.Color = RGB(64, 64, 255)
End With
With .Axes(xlCategory, xlPrimary)
.HasTitle = True
With .AxisTitle
.Font.Size = 14
'.Font.Bold = True
.Characters.Text = "Zeit [s]"
End With
.HasMajorGridlines = True
.HasMinorGridlines = True
End With
With .Axes(xlValue, xlPrimary)
.HasTitle = True
With .AxisTitle
.Font.Size = 14
'.Font.Bold = True
.Characters.Text = "Elektrische Aktivität [µV]"
End With
.HasMajorGridlines = True
.HasMinorGridlines = True
End With
End With
Bookmarks