PDA

View Full Version : Scanning data series and plotting based on data



gvan
04-21-2010, 10:52 AM
New to the Forum. Would like to try and scan through a column of data, if the correct data is present in the cell, then add a data series to plot. something like this:

Sub plotVoltage()
Sheets("Voltage Plots").Select

' Find number of data rows
With ActiveSheet
' find last row with data
LastRow = .Range("A65536").End(xlUp).Row
' set the start row for reading.
datastart = 38
End With

' Remove all Current Series except the spec ranges
ActiveSheet.ChartObjects("Chart 2").Activate
With ActiveChart
Do Until .SeriesCollection.count = 11
.SeriesCollection(3).Delete
Loop
End With

Dim count As Integer
count = DataStart
For count = count To LastRow
ActiveSheet.Range ("D" & count)
If ActiveSheet.Range.Value = "1.275V" Then ':::::THIS IS WHERE IT FAILS
With ActiveChart.SeriesCollection.NewSeries
.Name = ActiveSheet.Range("G" & count)
.Values = ActiveSheet.Range("G & count:G & count")
.XValues = ActiveSheet.Range("H & count:V & count")
.MarkerSize = 5
.MarkerStyle = xlMarkerStyleSquare
.ShowSeriesName = False
.Format.Line.DashStyle = msoLineDash
End With
End If
Next
End Sub

georgiboy
04-22-2010, 11:12 AM
Welcome to the forum

Have you tried changing these two lines...
ActiveSheet.Range ("D" & count)
If ActiveSheet.Range.Value = "1.275V" Then ':::::THIS IS WHERE IT FAILS
to just this one line...
If ActiveSheet.Range("D" & count).Value = "1.275V" Then

If this fails then upload a dummy workbook for us to look at.

Hope this helps