Scatter graph learning curve.
Hello all. I am trying a simple method of creating a scatter graph using the code below. This is using the macro recording but eventually I would like to apply this to capture data on multiple sheets and creating multiple graphs on the same page, but for now this is to get a better understanding.
I would like to create a scatter graph where the range in each column can either finish at lets say A30 or A45 as the data set can change...how would I capture the 'unknown range in each column...e.g..
[TABLE="width: 500"]
<tbody>[TR]
[TD]Data[/TD]
[TD]X[/TD]
[TD]Y[/TD]
[/TR]
[TR]
[TD]11[/TD]
[TD]15[/TD]
[TD]132[/TD]
[/TR]
[TR]
[TD]154[/TD]
[TD]158[/TD]
[TD]4[/TD]
[/TR]
[TR]
[TD]1254[/TD]
[TD]458[/TD]
[TD]8883[/TD]
[/TR]
[TR]
[TD]45[/TD]
[TD]8[/TD]
[TD]4863[/TD]
[/TR]
[TR]
[TD]454[/TD]
[TD]45848[/TD]
[TD]453[/TD]
[/TR]
[TR]
[TD]4882[/TD]
[TD]45[/TD]
[TD]448[/TD]
[/TR]
[TR]
[TD]8564[/TD]
[TD]75[/TD]
[TD]458[/TD]
[/TR]
[TR]
[TD]5888[/TD]
[TD]15[/TD]
[TD]487[/TD]
[/TR]
[TR]
[TD]878[/TD]
[TD]49[/TD]
[TD]69[/TD]
[/TR]
[TR]
[TD]689[/TD]
[TD]987[/TD]
[TD]65[/TD]
[/TR]
</tbody>[/TABLE]
The code I have below:
Not sure if that makes sense but the code above does not work.
Basically I would like something dynamic as the range of data will be unknown. The range of data will have to be ( Data/X) and ( Data /Y )..
Am I going in the right direction? Please may someone help.
Hello all. I am trying a simple method of creating a scatter graph using the code below. This is using the macro recording but eventually I would like to apply this to capture data on multiple sheets and creating multiple graphs on the same page, but for now this is to get a better understanding.
I would like to create a scatter graph where the range in each column can either finish at lets say A30 or A45 as the data set can change...how would I capture the 'unknown range in each column...e.g..
[TABLE="width: 500"]
<tbody>[TR]
[TD]Data[/TD]
[TD]X[/TD]
[TD]Y[/TD]
[/TR]
[TR]
[TD]11[/TD]
[TD]15[/TD]
[TD]132[/TD]
[/TR]
[TR]
[TD]154[/TD]
[TD]158[/TD]
[TD]4[/TD]
[/TR]
[TR]
[TD]1254[/TD]
[TD]458[/TD]
[TD]8883[/TD]
[/TR]
[TR]
[TD]45[/TD]
[TD]8[/TD]
[TD]4863[/TD]
[/TR]
[TR]
[TD]454[/TD]
[TD]45848[/TD]
[TD]453[/TD]
[/TR]
[TR]
[TD]4882[/TD]
[TD]45[/TD]
[TD]448[/TD]
[/TR]
[TR]
[TD]8564[/TD]
[TD]75[/TD]
[TD]458[/TD]
[/TR]
[TR]
[TD]5888[/TD]
[TD]15[/TD]
[TD]487[/TD]
[/TR]
[TR]
[TD]878[/TD]
[TD]49[/TD]
[TD]69[/TD]
[/TR]
[TR]
[TD]689[/TD]
[TD]987[/TD]
[TD]65[/TD]
[/TR]
</tbody>[/TABLE]
The code I have below:
HTML:
Sub CommandButton_Click()
With ActiveSheet.ChartObjects.Add(Left:=100,Width:=375,Top:=75, Height:=225)
.chart.SetSourceData Source:=Sheets("Sheets2").range("A2:A10").range("B2:B10")
.chart.ChartType = xlXYScatterLines
End With
End Sub
Not sure if that makes sense but the code above does not work.
Basically I would like something dynamic as the range of data will be unknown. The range of data will have to be ( Data/X) and ( Data /Y )..
Am I going in the right direction? Please may someone help.