Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default 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
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
random integer with sum constraint Karin[_2_] Excel Worksheet Functions 8 January 6th 10 09:13 PM
Help Programming Limit Constraint Suz84[_2_] Excel Programming 0 August 2nd 06 01:58 PM
Adding a constraint. AhmtDY Excel Discussion (Misc queries) 2 May 6th 05 09:59 AM
cell value constraint Balder Excel Discussion (Misc queries) 2 April 18th 05 07:14 PM
solver constraint jojo Excel Worksheet Functions 0 February 17th 05 10:11 PM


All times are GMT +1. The time now is 05:26 AM.

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

About Us

"It's about Microsoft Excel"