Text Box Calculation

C

caseyalta

I have 3 textboxes on a report that total number of unit sales between
specific dates. I want to add a textbox and have it calculate the highest
number of the other 3 to use in another calculation
 
M

Marshall Barton

caseyalta said:
I have 3 textboxes on a report that total number of unit sales between
specific dates. I want to add a textbox and have it calculate the highest
number of the other 3 to use in another calculation


=IIf(t1 > IIf(t2 > t3, t2, t3), t1, IIf(t2 > t3, t2, t3))

That kind of expression gets very messy very quickly, so
it's almost always better to create a function to do the
calculation:

Public Function MaxOfList(ParamArray vValues() As Variant)
As Variant
Dim vX As Variant

MaxOfList = vValues(0)
For Each vX In vValues
If vX >= Nz(MaxOfList, vX) Then MaxOfList = vX
Next vX
End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top