Graph an ln function

sarahrosenberg

Board Regular
Joined
Aug 27, 2002
Messages
190
I need to creat a graph using an ln function, and am not sure how to do this in Excel 2007.

My formula is y=-0.25ln(x)+1 How do I tell Excel to put this in a graph, or can I?
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
HTH. Dave
Code:
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
 
Upvote 0

Forum statistics

Threads
1,224,552
Messages
6,179,486
Members
452,917
Latest member
MrsMSalt

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top