Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help Programming Limit Constraint
Hey All, Just a quick question. I have a function called -IndexSim- and woul like to set an IF statement so that it is inbetween two values -UpperRange- and -LowerRange-. I have used the following: Code ------------------- If IndexSim(Cnt) = LowerRange And IndexSim(Cnt) <= UpperRange Then ------------------- Is this correct, as I don't think it produces the outcome I want? Please advise, Many thanks, Suz8 -- Suz8 ----------------------------------------------------------------------- Suz84's Profile: http://www.excelforum.com/member.php...fo&userid=3618 View this thread: http://www.excelforum.com/showthread.php?threadid=56741 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help Programming Limit Constraint
You are showing code that suggests that IndexSim is an array, whereas you
call it a function. They are very different (although a function could return an array), so how about showing the indexSim code. -- HTH Bob Phillips (replace somewhere in email address with gmail if mailing direct) "Suz84" wrote in message ... Hey All, Just a quick question. I have a function called -IndexSim- and would like to set an IF statement so that it is inbetween two values, -UpperRange- and -LowerRange-. I have used the following: Code: -------------------- If IndexSim(Cnt) = LowerRange And IndexSim(Cnt) <= UpperRange Then -------------------- Is this correct, as I don't think it produces the outcome I want? Please advise, Many thanks, Suz84 -- Suz84 ------------------------------------------------------------------------ Suz84's Profile: http://www.excelforum.com/member.php...o&userid=36189 View this thread: http://www.excelforum.com/showthread...hreadid=567415 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help Programming Limit Constraint
IndexSim is simply a value to a function, that is what I meant to say: Code ------------------- IndexSim(Cnt) = gBmProcess(Kt, r, q, Vol, TMat - TNow) ------------------- It produces a value which I would like to know if it is within th constraint above -- Suz8 ----------------------------------------------------------------------- Suz84's Profile: http://www.excelforum.com/member.php...fo&userid=3618 View this thread: http://www.excelforum.com/showthread.php?threadid=56741 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help Programming Limit Constraint
I wouldn't call it twice
Dim idex as Long idex = IndexSim(cnt) if idex < lowerRange then idex = lowerRange elseif idex upperRange then idex = UpperRange end if maybe what you are looking for. If you just want to validate the result, then your approach is correct. Dim idex as Long idex = IndexSim(cnt) If idex = LowerRange And idex <= UpperRange Then Msgbox "within bounds" else Msgbox "Outside of bounds" End if If you mean within the function Public Function IdexSim(cnt as Long) Const UpperRange as Long = 100 Const LowerRange as Long = 50 if cnt UpperRange then IdexSim = UpperRange elseif cnt < LowerRange then IdexSim = LowerRange else IdexSim = cnt end if End Function -- Regards, Tom Ogilvy "Suz84" wrote: Hey All, Just a quick question. I have a function called -IndexSim- and would like to set an IF statement so that it is inbetween two values, -UpperRange- and -LowerRange-. I have used the following: Code: -------------------- If IndexSim(Cnt) = LowerRange And IndexSim(Cnt) <= UpperRange Then -------------------- Is this correct, as I don't think it produces the outcome I want? Please advise, Many thanks, Suz84 -- Suz84 ------------------------------------------------------------------------ Suz84's Profile: http://www.excelforum.com/member.php...o&userid=36189 View this thread: http://www.excelforum.com/showthread...hreadid=567415 |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help Programming Limit Constraint
What you show would indicate IndexSim is an array
Dim IndexSim(1 to 20) as Double for cnt = 1 to 20 ' code that changes inputs to gBmProcess IndexSim(cnt) = IndexSim(Cnt) = gBmProcess(Kt, r, q, Vol, TMat - TNow) if indexSim(cnt) = LowerRange and IndexSim(cnt) <= UpperRange then msgbox cnt & ". " & IndexSim(cnt) " & is within bounds" else msgbox cnt & ". " & indexSim(cnt) & " is out of bounds" end if Next -- Regards, Tom Ogilvy "Suz84" wrote: IndexSim is simply a value to a function, that is what I meant to say: Code: -------------------- IndexSim(Cnt) = gBmProcess(Kt, r, q, Vol, TMat - TNow) -------------------- It produces a value which I would like to know if it is within the constraint above. -- Suz84 ------------------------------------------------------------------------ Suz84's Profile: http://www.excelforum.com/member.php...o&userid=36189 View this thread: http://www.excelforum.com/showthread...hreadid=567415 |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help Programming Limit Constraint
and I repeat what I said previously.
-- HTH Bob Phillips (replace somewhere in email address with gmail if mailing direct) "Tom Ogilvy" wrote in message ... What you show would indicate IndexSim is an array Dim IndexSim(1 to 20) as Double for cnt = 1 to 20 ' code that changes inputs to gBmProcess IndexSim(cnt) = IndexSim(Cnt) = gBmProcess(Kt, r, q, Vol, TMat - TNow) if indexSim(cnt) = LowerRange and IndexSim(cnt) <= UpperRange then msgbox cnt & ". " & IndexSim(cnt) " & is within bounds" else msgbox cnt & ". " & indexSim(cnt) & " is out of bounds" end if Next -- Regards, Tom Ogilvy "Suz84" wrote: IndexSim is simply a value to a function, that is what I meant to say: Code: -------------------- IndexSim(Cnt) = gBmProcess(Kt, r, q, Vol, TMat - TNow) -------------------- It produces a value which I would like to know if it is within the constraint above. -- Suz84 ------------------------------------------------------------------------ Suz84's Profile: http://www.excelforum.com/member.php...o&userid=36189 View this thread: http://www.excelforum.com/showthread...hreadid=567415 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
random integer with sum constraint | Excel Worksheet Functions | |||
Help Programming Limit Constraint | Excel Programming | |||
Adding a constraint. | Excel Discussion (Misc queries) | |||
cell value constraint | Excel Discussion (Misc queries) | |||
solver constraint | Excel Worksheet Functions |