Sub ChartFunction()
'charts function on sheet 1
Dim ChartRange As Range, Xvalue As Range, Yvalue As Range, Increment As Double
Dim Xmin As Double, Xmax As Double, Iter As Integer, Cnt As Integer
Application.ScreenUpdating = False
'change values below to suit
Iter = 100 'Number of chart points
Xmin = 0.001 'lowest "X" value *** > 0 for this eg.
Xmax = 10 'highest "X" value
'chrt pt increments
Increment = (Xmax - Xmin) / (Iter - 1)
On Error Resume Next
'make chart y data with f(x)
For Cnt = 1 To Iter
Sheets("sheet1").Cells(Cnt, 1) = Xmin '"X" value
' "Y" value generated by function for "X" value eg. 2 * Sin(3 * Xmin) + 8
'Sheets("sheet1").Cells(Cnt, 2) = ((-7) * (3 * Xmin ^ 2)) + (2 * Xmin / 5) - 6
'Sheets("sheet1").Cells(Cnt, 2) = 2 * Sin(3 * Xmin) + 8
Sheets("sheet1").Cells(Cnt, 2) = Application.WorksheetFunction.Ln(Xmin) * -0.25 + 1
Xmin = Xmin + Increment
Next Cnt
'make chart
Set Xvalue = Sheets("sheet1").Cells(1, 1)
Set Yvalue = Sheets("sheet1").Cells(Iter, 2)
Set ChartRange = Sheets("sheet1").Range(Xvalue, Yvalue)
Charts.Add
ActiveChart.ChartType = xlXYScatterSmoothNoMarkers
ActiveChart.SetSourceData Source:=ChartRange, PlotBy:=xlColumns
ActiveChart.Location Where:=xlLocationAsObject, Name:="Sheet1"
Application.ScreenUpdating = True
End Sub