programme fucntioning problems errors

P

paul

number,x, from cell A3 and a positive integer, n, from cell B3 then
returns into cell C3 the value of x raised to the power n divided by
n factorial.

where x in cell a3 = 2 and n in cell b3 = 5


im using this formula, but when i run it nothing happens, how do i
make this vba programme run and return the value?


the vba programmes is ok its just no running anything or doing
anything
to my spreadsheet when i need it to return into cell C3


i think i need to delcare the vaiables, but not sure how to doo it.


basically i need help in order for my spreasheet of the numbers x and
n to return in cell a3 the value of x raised tot he power n divided
by
n factorial but nothin is happening in the spreadhseet, can any one
tell me or show me how to do this


please i really want to do this, but cant


this is the vba programme:


Public Function MyFunction(X As Double, N As Long) As Variant
If (N <= 0&) _
Then
MyFunction = "N must be an integer greater than zero"
Else
MyFunction = (X ^ N) / WorksheetFunction.Fact(N)
End If
End Function
 
J

JW

The functhin works fine for me. Might want to put in
Application.Volatile though so that the formula is recalculated each
time a change takes place on the worksheet.
Public Function MyFunction(X As Double, N As Long) As Variant
Application.Volatile
If (N <= 0) Then
MyFunction = "N must be an integer greater than zero"
Else
MyFunction = (X ^ N) / WorksheetFunction.Fact(N)
End If
End Function
 
G

Guest

The code worrks ok. You don't need to declare variables. If you did you
would of gotten an error. Make sure you placed the code on a module page in
VBA.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

running a programme 9
programme run help 2
running varibiables into vba 1
vba 2
PROGRAMME HELP 2
vba coding 3
run programme error occuring 2
continous assessment help with vba 1

Top