|
-
Jul 26th, 2005, 01:37 PM
#1
Thread Starter
Junior Member
[RESOLVED] type mismatch
Im not sure if this is the correct place to post this query but i hope so.
Why do i get a type mismatch Run-time error 13, for the following piece of code???
VB Code:
returns(a) = "=Average(loser["& a &" "& b &"]:loser ["& a &" "& b+10 &"])"
If returns(a) and loser(a, b) are defined as Single then why is there a mismatch?
Any help would be most appreciated.
Last edited by Zahida.Laljee; Jul 26th, 2005 at 01:53 PM.
-
Jul 26th, 2005, 01:47 PM
#2
PowerPoster
Re: type mismatch
You have a string on ther right side of the equation, but there is no quote to close it
-
Jul 26th, 2005, 01:51 PM
#3
Thread Starter
Junior Member
Re: type mismatch
that was a typo in my question there is quotation to close it - but thanks
-
Jul 26th, 2005, 01:58 PM
#4
Re: type mismatch
Uhh, seems to me you're assigning a string to a single then
I dont exactly understand what that line of code is trying to do though
-
Jul 26th, 2005, 02:10 PM
#5
Thread Starter
Junior Member
Re: type mismatch
Loser() contains values that need to be used to calculate the average returns.
so although it is entering a string into the array component of returns(a) it is supposed to enter the average value of loser(a,b) and loser(a, b+1). Does that make any sense?
-
Jul 26th, 2005, 02:13 PM
#6
Re: type mismatch
not exactly to me , however, simply looking at
"=Average()" leads me to believe it is a string..the average function is meant to be used with single values is it not?
-
Jul 26th, 2005, 02:38 PM
#7
Re: type mismatch
Are you using Excel? It required cell reference as A1, and loser(1,1) won't work.
-
Jul 26th, 2005, 04:21 PM
#8
Thread Starter
Junior Member
Re: type mismatch
but the value is contained in loser array component(1,1)?!?!?
-
Jul 26th, 2005, 06:12 PM
#9
Re: type mismatch
im just gonna remove the strings..is this what you want?
returns(a) = Average(loser[a,b]:loser [a,b+10])
?
-
Jul 27th, 2005, 05:20 AM
#10
Thread Starter
Junior Member
Re: type mismatch
but that doesn't compile because a list seperator or ) needed?
zee xxx
-
Jul 27th, 2005, 07:28 AM
#11
Re: type mismatch
This is Excel isn't it? You are using the : symbol to indicate a range?
-
Jul 27th, 2005, 07:31 AM
#12
Re: type mismatch
Or is this what you want?
VB Code:
Dim i As Long
Dim sngAvg As Single
For i = b To (b + 10)
sngAvg = sngAvg + Loser(a, i)
Next i
sngAvg = sngAvg / 11
Returns(a) = sngAvg
?
-
Jul 27th, 2005, 08:47 AM
#13
Thread Starter
Junior Member
Re: type mismatch
thank you very much
-
Jul 27th, 2005, 08:54 AM
#14
Re: type mismatch
No worries, I take it the second one did it 
Please mark your thread resolved using the Thread Tools menu.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|