Max/Min Functions
- From: "Greg Maxey" <gmaxey@xxxxxxxxxxxxxxxxxxx>
- Date: Fri, 2 Dec 2005 23:02:15 -0500
I put together the following little snippet of code to determine Max/Min
values with two arguments. I think it was JGM that posted the min function
a while back and I just reversed the equality signs to make the max function
work:
Sub Test()
Dim i As Long
i = min(1, 1000)
MsgBox i
i = max(5, 500)
MsgBox i
End Sub
Private Function min(a As Long, b As Long)
min = -((a < b) * a + (a >= b) * b)
End Function
Private Function max(a As Long, b As Long)
max = -((a > b) * a + (a <= b) * b)
End Function
Does anyone know if someone has figure out how to determine max or min
values in an array using Word VBA? Thanks.
--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.
.
- Follow-Ups:
- Re: Max/Min Functions
- From: Klaus Linke
- Re: Max/Min Functions
- From: Jonathan West
- Re: Max/Min Functions
- From: Jezebel
- Re: Max/Min Functions
- Prev by Date: Re: Run-time error '4605'
- Next by Date: Re: macros using 2 open documents.
- Previous by thread: Re: Word's paragraph formating sucks, learn from FrameMaker
- Next by thread: Re: Max/Min Functions
- Index(es):
Relevant Pages
|
Loading