The code is meant to take a set of 10,000 observations of variable x and y and plug each observation set into the equation defined as fin and take the average of the results. For some reason when I try to use the average function when defining the cell(2,7) it is saying that the average function is not defined. Also for a while i was having trouble with the exp predefined function when trying to define fin(i) until i finally copyed and pasted the function from the worksheet. And again with defining the t(i) variable I tryed to use the SQRT() predefined function until I restated it the way it is now. can anyone tell me why vba is having trouble recognizing its functions when I type them in in a value statement?
Sub udsim3() Dim x(1 To 10000), y(1 To 10000), t(1 To 10000), fin(1 To 10000), i For i = 1 To 10000 x(i) = Cells(2 * i + 9999, "D") y(i) = Cells(2 * i + 10000, "D") t(i) = (y(i) ^ (0.5)) * x(i) fin(i) = Exp((-3 * t(i)) - y(i)) * (y(i) ^ 1.5) * (1 + 3 * t(i)) Cells(i + 1, "P") = fin(i) Next i Cells(2, 7) = Average(fin) End Sub
Last edited by Truss123; 01-23-2012 at 12:52 PM.
Average is an Excel function, not VBA
Cells(2, 7).Value = WorksheetFunction.Average(fin)
Microsoft MVP - Excel
Entia non sunt multiplicanda sine necessitate
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks