PC Review


Reply
Thread Tools Rate Thread

coding and helping to launch vba

 
 
biker man
Guest
Posts: n/a
 
      18th Sep 2007
im using the following code

Sub test()
Dim x As Single, n As Integer, i As Integer, fact As Integer
n = Range("b3")
x = Range("a3")
'calculate n factorial
'checking B3
If Range("B3") <= 0 Or Int(Range("B3")) < Range("B3") Then
MsgBox " integer in b3 must be greater then zero"
Exit Sub
End If
fact = 1
For i = 1 To n
fact = fact * 1
Next i
'calculate result x ^ n/fact n!
result = x ^ n / fact
Range("c3") = result


where n =5 and x = 2 but is running into cell c3 32, which is 2 to
the
power 5 factorial


but i want to run 2 to the power 5 divided by n factorial, does
anyone
no anything i can put into this vba code to make it return this.


also i want to add some error checking, does anyone know how to add
that to the vba code


thanks

 
Reply With Quote
 
 
 
 
=?Utf-8?B?TWlrZSBI?=
Guest
Posts: n/a
 
      18th Sep 2007
see your other post

"biker man" wrote:

> im using the following code
>
> Sub test()
> Dim x As Single, n As Integer, i As Integer, fact As Integer
> n = Range("b3")
> x = Range("a3")
> 'calculate n factorial
> 'checking B3
> If Range("B3") <= 0 Or Int(Range("B3")) < Range("B3") Then
> MsgBox " integer in b3 must be greater then zero"
> Exit Sub
> End If
> fact = 1
> For i = 1 To n
> fact = fact * 1
> Next i
> 'calculate result x ^ n/fact n!
> result = x ^ n / fact
> Range("c3") = result
>
>
> where n =5 and x = 2 but is running into cell c3 32, which is 2 to
> the
> power 5 factorial
>
>
> but i want to run 2 to the power 5 divided by n factorial, does
> anyone
> no anything i can put into this vba code to make it return this.
>
>
> also i want to add some error checking, does anyone know how to add
> that to the vba code
>
>
> thanks
>
>

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Hi everyone and thanks for helping Mike Windows XP Help 1 17th Dec 2007 01:37 PM
Thanks for helping me =?Utf-8?B?U3RhbmxleQ==?= Windows XP General 1 26th Sep 2006 11:01 PM
Thanks for helping sonar Microsoft Excel Worksheet Functions 0 17th Apr 2004 05:03 PM
no one is helping... ramon Microsoft Access Form Coding 2 25th Nov 2003 08:51 AM
HtmlSelect control is not helping and client side coding became a real headache Suhail A, Salman Microsoft ASP .NET 0 13th Aug 2003 11:38 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:34 AM.