Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
a a is offline
external usenet poster
 
Posts: 51
Default I don't think this is an easy one

Hello,

I'm not sure why this will not work - but I'm pretty sure one of you
will. The error I get when I run this is a "type mismatch". I did
declare the variables but then I undeclared them just to see whether
that was the problem.

Can anybody help?

Thanks much in advance,
Anita

node = TopValue
nodenumber = 0
degree = t - nodenumber
s = 100
x = 100
t = 16
r = 0
sd = 0.05
n = 1000

prob = "=Fact(" & t & ")" & "/" & "Fact" & (nodenumber) & "*" &
"Fact(" & degree & ") * " & 0.5 ^ nodenumber * (0.5 ^ " & degree & ")


Range("h14").Formula = prob




End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default I don't think this is an easy one

(0.5 ^ " & degree & ")

causes the problem. You are trying to raise 0.5 to the "& degree &" power.
Looks like your quotes are messed up.

--
Regards,
Tom Ogilvy


"a" wrote in message
link.net...
Hello,

I'm not sure why this will not work - but I'm pretty sure one of you
will. The error I get when I run this is a "type mismatch". I did
declare the variables but then I undeclared them just to see whether
that was the problem.

Can anybody help?

Thanks much in advance,
Anita

node = TopValue
nodenumber = 0
degree = t - nodenumber
s = 100
x = 100
t = 16
r = 0
sd = 0.05
n = 1000

prob = "=Fact(" & t & ")" & "/" & "Fact" & (nodenumber) & "*" &
"Fact(" & degree & ") * " & 0.5 ^ nodenumber * (0.5 ^ " & degree & ")


Range("h14").Formula = prob




End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default I don't think this is an easy one

You also use t in a statement, setting degree, before you assign a value to
t, which returns a lot of zeroes in your formula.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Tom Ogilvy" wrote in message
...
(0.5 ^ " & degree & ")

causes the problem. You are trying to raise 0.5 to the "& degree &"

power.
Looks like your quotes are messed up.

--
Regards,
Tom Ogilvy


"a" wrote in message
link.net...
Hello,

I'm not sure why this will not work - but I'm pretty sure one of you
will. The error I get when I run this is a "type mismatch". I did
declare the variables but then I undeclared them just to see whether
that was the problem.

Can anybody help?

Thanks much in advance,
Anita

node = TopValue
nodenumber = 0
degree = t - nodenumber
s = 100
x = 100
t = 16
r = 0
sd = 0.05
n = 1000

prob = "=Fact(" & t & ")" & "/" & "Fact" & (nodenumber) & "*" &
"Fact(" & degree & ") * " & 0.5 ^ nodenumber * (0.5 ^ " & degree & ")


Range("h14").Formula = prob




End Sub





  #4   Report Post  
Posted to microsoft.public.excel.programming
a a is offline
external usenet poster
 
Posts: 51
Default I don't think this is an easy one

Okay, with the help of Tom Ogilvy and Bob Phillips, this thing now
works. Now I'm wondering whether there is a way that I could have it as
a custom function. Would anybody be able to help?

Thanks in advance,
Anita



node = TopValue

s = 100
x = 100
t = 16
r = 0
sd = 0.05
n = 1000
nodenumber = 0
degree = t - nodenumber


prob = "=Fact(" & t & ")" & "/" & "(Fact" & "(" & nodenumber & ")"
& "*" & "Fact(" & degree & "))" & "*" & "(" & 0.5 ^ nodenumber & ")" &
"*" & "(" & 0.5 ^ degree & ")"
Range("h13").Formula = prob



End Sub

Bob Phillips wrote:

You also use t in a statement, setting degree, before you assign a value to
t, which returns a lot of zeroes in your formula.


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default I don't think this is an easy one

Quite straightforward

Function Prob
t = 16
nodenumber = 0
degree = t - nodenumber

prob = "=Fact(" & t & ")" & "/" & "(Fact" & "(" & nodenumber & _
")" & "*" & "Fact(" & degree & "))" & "*" & _
"(" & 0.5 ^ nodenumber & ")" & "*" & "(" & 0.5 ^ degree &
")"
End Function

If you want, you can pass t and nodenumber as arguments

Function Prob(t, nodenumber)
degree = t - nodenumber
prob = "=Fact(" & t & ")" & "/" & "(Fact" & "(" & nodenumber & _
")" & "*" & "Fact(" & degree & "))" & "*" & _
"(" & 0.5 ^ nodenumber & ")" & "*" & "(" & 0.5 ^ degree &
")"
End Function

and call like

=Prob(16,0)

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"a" wrote in message
link.net...
Okay, with the help of Tom Ogilvy and Bob Phillips, this thing now
works. Now I'm wondering whether there is a way that I could have it as
a custom function. Would anybody be able to help?

Thanks in advance,
Anita



node = TopValue

s = 100
x = 100
t = 16
r = 0
sd = 0.05
n = 1000
nodenumber = 0
degree = t - nodenumber


prob = "=Fact(" & t & ")" & "/" & "(Fact" & "(" & nodenumber & ")"
& "*" & "Fact(" & degree & "))" & "*" & "(" & 0.5 ^ nodenumber & ")" &
"*" & "(" & 0.5 ^ degree & ")"
Range("h13").Formula = prob



End Sub

Bob Phillips wrote:

You also use t in a statement, setting degree, before you assign a value

to
t, which returns a lot of zeroes in your formula.






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 690
Default I don't think this is an easy one

...whether there is a way that I could have it as
a custom function.


Do you mean as a function that returns a value? Just one idea...

Function Prob(t, nodenumber)
'= = = = =
' t!/(2^t*nodenumber!*(t - nodenumber)!)
'= = = = =
With WorksheetFunction
Prob = .Fact(t) / ((2 ^ t) * .Fact(nodenumber) * .Fact(t - nodenumber))
End With
End Function

HTH.
Dana DeLouis


"a" wrote in message
link.net...
Okay, with the help of Tom Ogilvy and Bob Phillips, this thing now
works. Now I'm wondering whether there is a way that I could have it as
a custom function. Would anybody be able to help?

Thanks in advance,
Anita



node = TopValue

s = 100
x = 100
t = 16
r = 0
sd = 0.05
n = 1000
nodenumber = 0
degree = t - nodenumber


prob = "=Fact(" & t & ")" & "/" & "(Fact" & "(" & nodenumber & ")"
& "*" & "Fact(" & degree & "))" & "*" & "(" & 0.5 ^ nodenumber & ")" &
"*" & "(" & 0.5 ^ degree & ")"
Range("h13").Formula = prob



End Sub

Bob Phillips wrote:

You also use t in a statement, setting degree, before you assign a value

to
t, which returns a lot of zeroes in your formula.




  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 690
Default I don't think this is an easy one

Oops! Didn't see this earlier.

Function Prob(t, nodenumber)
With WorksheetFunction
Prob = 2 ^ -t * .Combin(t, nodenumber)
End With
End Function

HTH.
Dana DeLouis

"Dana DeLouis" wrote in message
...
...whether there is a way that I could have it as
a custom function.


Do you mean as a function that returns a value? Just one idea...

Function Prob(t, nodenumber)
'= = = = =
' t!/(2^t*nodenumber!*(t - nodenumber)!)
'= = = = =
With WorksheetFunction
Prob = .Fact(t) / ((2 ^ t) * .Fact(nodenumber) * .Fact(t -

nodenumber))
End With
End Function

HTH.
Dana DeLouis


"a" wrote in message
link.net...
Okay, with the help of Tom Ogilvy and Bob Phillips, this thing now
works. Now I'm wondering whether there is a way that I could have it as
a custom function. Would anybody be able to help?

Thanks in advance,
Anita



node = TopValue

s = 100
x = 100
t = 16
r = 0
sd = 0.05
n = 1000
nodenumber = 0
degree = t - nodenumber


prob = "=Fact(" & t & ")" & "/" & "(Fact" & "(" & nodenumber & ")"
& "*" & "Fact(" & degree & "))" & "*" & "(" & 0.5 ^ nodenumber & ")" &
"*" & "(" & 0.5 ^ degree & ")"
Range("h13").Formula = prob



End Sub

Bob Phillips wrote:

You also use t in a statement, setting degree, before you assign a

value
to
t, which returns a lot of zeroes in your formula.






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Easy One! Skydiver Excel Discussion (Misc queries) 4 March 11th 10 10:06 PM
This will be really easy, I'm sure Jamie Excel Discussion (Misc queries) 9 December 5th 08 05:30 PM
There must be an easy way? kassie Excel Discussion (Misc queries) 5 May 26th 07 06:33 AM
pls help, is there an easy way to [email protected] Excel Worksheet Functions 12 May 3rd 07 07:04 PM
new user with easy question? not easy for me speakeztruth New Users to Excel 5 June 3rd 05 09:40 PM


All times are GMT +1. The time now is 04:12 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"