S
spacemancw
Below is the macro that I currently use and it works well
Starting at column(i) it draws a graph with Y axis of column(i) and X
axis of column(1)
The macro starts of by declaring the value of i
--------------------------------------------
Dim i As Integer
i = 2
Do While (Not IsEmpty(ActiveSheet.Cells(2, i)))
ActiveChart.SetSourceData Source:=Sheets("Sheet1").Columns(i),
PlotBy:=xlColumns
ActiveChart.SeriesCollection(1).XValues = "=Sheet1!R2C1:R360C1"
i = i + 1
Loop
--------------------------------------------
I have a different data set now where I am interested in XY graphing
columns 4 and 3 .... 6 and 5 ... 8 and 7 .... 10 and 9 .. and so on
But the final amount of pairs can vary in each data set.
Now I wanna change the macro so that Y axis is column(i) and X axis is
column(i - 1)
--------------------------------------------
Dim i As Integer
i = 4
Do While (Not IsEmpty(ActiveSheet.Cells(2, i)))
ActiveChart.SetSourceData Source:=Sheets("Sheet1").Columns(i),
PlotBy:=xlColumns
ActiveChart.SeriesCollection(1).XValues = "=Sheet1!R2C(i -
1):R360C(i - 1)"
i = i + 2
Loop
--------------------------------------------
As you can see I've refered to the column as C(i - 1) .... this
doesn't work .. obviously not the correct syntax
Do you know how to get this part to work?
thanx
Roger
Sub Manycols()
'
' Manycols Macro
' Macro recorded 6/23/2003 by djason
'
Dim i As Integer
i = 4
Do While (Not IsEmpty(ActiveSheet.Cells(2, i)))
z = i - 1
Charts.Add
'ActiveChart.ChartType = xlLine
ActiveChart.ChartType = xlXYScatterLines
ActiveChart.SetSourceData Source:=Sheets("Sheet1").Columns(i),
PlotBy:=xlColumns
'ActiveChart.SeriesCollection(1).XValues = "=Sheet1!R2C1:R360C1"
ActiveChart.SeriesCollection(1).XValues = "=Sheet1!R2Ci:R360Ci"
ActiveChart.Location Where:=xlLocationAsObject, Name:="Sheet1"
ActiveChart.HasLegend = False
With ActiveChart
.HasTitle = True
'.ChartTitle.Characters.Text = "Ratio1"
.Axes(xlValue, xlPrimary).HasTitle = False
End With
ActiveChart.Axes(xlValue).Select
With ActiveChart.Axes(xlValue)
'.MinimumScale = 0
'.MaximumScale = 3
'.MinorUnit = 0.02
'.MajorUnit = 1
.Crosses = xlCustom
.CrossesAt = 0
.ReversePlotOrder = False
.ScaleType = xlLinear
.DisplayUnit = xlNone
End With
ActiveChart.PlotArea.Select
With Selection.Border
.ColorIndex = 16
.Weight = xlThin
.LineStyle = xlContinuous
End With
Selection.Interior.ColorIndex = xlNone
i = i + 2
Loop
End Sub
Starting at column(i) it draws a graph with Y axis of column(i) and X
axis of column(1)
The macro starts of by declaring the value of i
--------------------------------------------
Dim i As Integer
i = 2
Do While (Not IsEmpty(ActiveSheet.Cells(2, i)))
ActiveChart.SetSourceData Source:=Sheets("Sheet1").Columns(i),
PlotBy:=xlColumns
ActiveChart.SeriesCollection(1).XValues = "=Sheet1!R2C1:R360C1"
i = i + 1
Loop
--------------------------------------------
I have a different data set now where I am interested in XY graphing
columns 4 and 3 .... 6 and 5 ... 8 and 7 .... 10 and 9 .. and so on
But the final amount of pairs can vary in each data set.
Now I wanna change the macro so that Y axis is column(i) and X axis is
column(i - 1)
--------------------------------------------
Dim i As Integer
i = 4
Do While (Not IsEmpty(ActiveSheet.Cells(2, i)))
ActiveChart.SetSourceData Source:=Sheets("Sheet1").Columns(i),
PlotBy:=xlColumns
ActiveChart.SeriesCollection(1).XValues = "=Sheet1!R2C(i -
1):R360C(i - 1)"
i = i + 2
Loop
--------------------------------------------
As you can see I've refered to the column as C(i - 1) .... this
doesn't work .. obviously not the correct syntax
Do you know how to get this part to work?
thanx
Roger
Sub Manycols()
'
' Manycols Macro
' Macro recorded 6/23/2003 by djason
'
Dim i As Integer
i = 4
Do While (Not IsEmpty(ActiveSheet.Cells(2, i)))
z = i - 1
Charts.Add
'ActiveChart.ChartType = xlLine
ActiveChart.ChartType = xlXYScatterLines
ActiveChart.SetSourceData Source:=Sheets("Sheet1").Columns(i),
PlotBy:=xlColumns
'ActiveChart.SeriesCollection(1).XValues = "=Sheet1!R2C1:R360C1"
ActiveChart.SeriesCollection(1).XValues = "=Sheet1!R2Ci:R360Ci"
ActiveChart.Location Where:=xlLocationAsObject, Name:="Sheet1"
ActiveChart.HasLegend = False
With ActiveChart
.HasTitle = True
'.ChartTitle.Characters.Text = "Ratio1"
.Axes(xlValue, xlPrimary).HasTitle = False
End With
ActiveChart.Axes(xlValue).Select
With ActiveChart.Axes(xlValue)
'.MinimumScale = 0
'.MaximumScale = 3
'.MinorUnit = 0.02
'.MajorUnit = 1
.Crosses = xlCustom
.CrossesAt = 0
.ReversePlotOrder = False
.ScaleType = xlLinear
.DisplayUnit = xlNone
End With
ActiveChart.PlotArea.Select
With Selection.Border
.ColorIndex = 16
.Weight = xlThin
.LineStyle = xlContinuous
End With
Selection.Interior.ColorIndex = xlNone
i = i + 2
Loop
End Sub