Hi
Got it sorted now after some help on another forum - completed code is :-
Public Sub makechart(datasheet As String, xaxis As String, yaxis As String, name As String)
Dim achart As Chart
Dim lastr As String
lastr = (lastrow(datasheet))
If Not IsNumeric(xaxis) Then xaxis = Range(xaxis & "1").Column
If Not IsNumeric(yaxis) Then yaxis = Range(yaxis & "1").Column
Charts.Add
ActiveChart.ChartType = xlXYScatter
'ActiveChart.SetSourceData Source:=Sheets("All Data").Range("A1:AV74"), _
PlotBy:=xlColumns
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(1).XValues = "='" & datasheet & "'!R2C" & xaxis & ":R" & lastr & "C" & xaxis
ActiveChart.SeriesCollection(1).Values = "='" & datasheet & "'!R2C" & yaxis & ":R" & lastr & "C" & yaxis
ActiveChart.Location Where:=xlLocationAsNewSheet
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "WR V WR top"
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "WR"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Vr"
End With
With ActiveChart.Axes(xlCategory)
.HasMajorGridlines = False
.HasMinorGridlines = False
End With
With ActiveChart.Axes(xlValue)
.HasMajorGridlines = False
.HasMinorGridlines = False
End With
ActiveChart.HasLegend = False
ActiveChart.PlotArea.Select
With Selection.Border
.Weight = xlThin
.LineStyle = xlNone
End With
Selection.Interior.ColorIndex = xlNone
End Sub
Cheers
Dave
|