Hi,
I'm new to Excel VBA, and just wrote a code (see below) to help me plot multiple plots from a number of ranges in a sheet, but it doesn't seem to work.
Regards,
I'm new to Excel VBA, and just wrote a code (see below) to help me plot multiple plots from a number of ranges in a sheet, but it doesn't seem to work.
Regards,
Code:
Sub Macro2()
Dim TopOld As Integer, TopNew As Integer, Bottom As Integer
TopOld = 16360
For i = 16360 To 31477
If Sheets("Sheet1").Cells(i, 1) <> Sheets("Sheet1").Cells(i + 1, 1) Then
TopNew = i + 1
Bottom = i
Charts.Add
ActiveChart.ChartType = xlLineMarkers
rangeC = "C" & TopOld & ":" & "C" & Bottom
rangeO = "O" & TopOld & ":" & "O" & Bottom
ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range("rangeC"), _
PlotBy:=xlColumns
ActiveChart.SeriesCollection(1).XValues = "=Sheet1!R" & TopOld & "C3:R" & Bottom & "C3"
ActiveChart.SeriesCollection(1).Values = "=Sheet1!R" & TopOld & "C15:R" & Bottom & "C15"
ActiveChart.Location Where:=xlLocationAsObject, Name:="Sheet1"
End If
TopOld = TopNew
Next i
End Sub