C
CLamar
I have some code that makes a plot of some data that is in an Excel wksht.
The code makes a plot but it isnt correct. The code now, does two plots
where each series is a set of y-values. I want a plot where there is a
series collection for x and y - values (F column should be x and G column
should be y). Below is the code any modifications would be helpful
Sub VRHCharts()
Dim LastCellx As Long
Dim LastCelly As Long
On Error Resume Next
Application.DisplayAlerts = False
Charts("VRH1").Delete
On Error GoTo 0
With Worksheets("datatable")
LastCellx = .Cells(.Rows.Count, "F").End(xlUp).Row
LastCelly = .Cells(.Rows.Count, "G").End(xlUp).Row
End With
Application.ScreenUpdating = False
Charts.Add
ActiveChart.Name = "VRH1"
With ActiveChart
.SeriesCollection.NewSeries
.SeriesCollection.Add _
Source:=Worksheets("datatable").Range("f2:F" & LastCellx)
.SeriesCollection.Add _
Source:=Worksheets("datatable").Range("g2:G" & LastCelly)
.HasTitle = True
.ChartType = xlXYScatterSmooth
.HasLegend = False
.ApplyDataLabels Type:=xlDataLabelsShowValue
.Axes(xlCategory).TickLabels.Orientation = xlHorizontal
.ChartTitle.Font.Bold = True
.ChartTitle.Font.Size = 12
.PlotArea.Top = 18
.PlotArea.Height = 162
.Axes(xlValue).MaximumScale = 0.6
.Deselect
End With
Application.ScreenUpdating = True
End Sub
The code makes a plot but it isnt correct. The code now, does two plots
where each series is a set of y-values. I want a plot where there is a
series collection for x and y - values (F column should be x and G column
should be y). Below is the code any modifications would be helpful
Sub VRHCharts()
Dim LastCellx As Long
Dim LastCelly As Long
On Error Resume Next
Application.DisplayAlerts = False
Charts("VRH1").Delete
On Error GoTo 0
With Worksheets("datatable")
LastCellx = .Cells(.Rows.Count, "F").End(xlUp).Row
LastCelly = .Cells(.Rows.Count, "G").End(xlUp).Row
End With
Application.ScreenUpdating = False
Charts.Add
ActiveChart.Name = "VRH1"
With ActiveChart
.SeriesCollection.NewSeries
.SeriesCollection.Add _
Source:=Worksheets("datatable").Range("f2:F" & LastCellx)
.SeriesCollection.Add _
Source:=Worksheets("datatable").Range("g2:G" & LastCelly)
.HasTitle = True
.ChartType = xlXYScatterSmooth
.HasLegend = False
.ApplyDataLabels Type:=xlDataLabelsShowValue
.Axes(xlCategory).TickLabels.Orientation = xlHorizontal
.ChartTitle.Font.Bold = True
.ChartTitle.Font.Size = 12
.PlotArea.Top = 18
.PlotArea.Height = 162
.Axes(xlValue).MaximumScale = 0.6
.Deselect
End With
Application.ScreenUpdating = True
End Sub