VBA (arrays problem)
This I think is what you want:
Sub Plot()
Dim X As Single
Dim Y As Single
Dim lngRow As Long
Dim StepValue As Single
Dim arrValues(1 To 5) As Double
arrValues(1) = 2
arrValues(2) = 3
arrValues(3) = 5
arrValues(4) = 2
arrValues(5) = 1
StepValue = (arrValues(2) - arrValues(1)) / (arrValues(3) - 1)
lngRow = 0
X = arrValues(1)
With Sheets(1).Range("A10")
Do While X <= arrValues(2)
.Offset(lngRow, 0) = X
Y = Application.WorksheetFunction.NormDist(X, _
arrValues(4), _
arrValues(5), _
False)
.Offset(lngRow, 1) = Y
X = X + StepValue
lngRow = lngRow + 1
Loop
End With
End Sub
RBS
"Ali Baba" wrote in message
...
hi
I wrote this code to help me to plot a normal distribuion curve.
Sub Plot()
Dim mu As Single
Dim segma As Single
Dim xFirst As Single
Dim xLast As Single
Dim X As Single
Dim Y As Single
Dim lngRow As Long
Dim StepValue As Single
Dim Steps As String
xFirst = Sheets(1).Range("B1")
xLast = Sheets(1).Range("B2")
Steps = Sheets(1).Range("B3")
mu = Sheets(1).Range("B4")
segma = Sheets(1).Range("B5")
StepValue = (xLast - xFirst) / (Steps - 1)
lngRow = 0
X = xFirst
With Sheets(1).Range("A10")
Do While X <= xLast
.Offset(lngRow, 0) = X
Y = Application.WorksheetFunction.NormDist(X, mu,
segma,
False)
.Offset(lngRow, 1) = Y
X = X + StepValue
lngRow = lngRow + 1
Loop
End With
End Sub
As you can see that the procedure generates points in columns A and B to
be
used to create the chart. Is it possible to generate the graph without
seeing these points on the sheet. I mean that you have an array.
Plz help!!
|