Minimum between Calc and set #

sellis

New Member
Joined
May 17, 2011
Messages
33
I am running a query and trying to figure out how to set up a function to get either the results of a calculation or 500 whichever is smaller. Any help would be greatly appreciated.
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Something like this but you didn't give much information as to what you are calculating and where.

Code:
Function CalcTest() As Long
Dim Calc As Long
   Calc = (x+y) * 2
      If Calc < 500 Then
         CalcTest = Calc
      Else
         CalcTest = 500
      End If
End Function
 
Upvote 0
Ok. I get what you said about more info. Sorry. What I have currently is Access 2010 and my query is currently ROUND(Rate*0.6667*40,2) where rate is pulling from a table. I need the result of that query to be less than the 500. I have no idea how to enter the information you gave me in my version of Access. :) Thanks for your quick answer though.
 
Upvote 0
No function needed if this is in a query. Just use this as a new field:

NewFieldNameHere:IIf(ROUND([Rate]*0.6667*40,2) < 500, ROUND([Rate]*0.6667*40,2), 500)
 
Last edited:
Upvote 0
That was sooo awesome. Took me a minute to get the syntax right and make it work for me, but it works perfectly. Thanks soooooo much.
 
Upvote 0

Forum statistics

Threads
1,224,530
Messages
6,179,373
Members
452,907
Latest member
Roland Deschain

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top