Results 1 to 4 of 4
  1. #1
    Star Lounger
    Join Date
    Apr 2003
    Location
    Kansas City, Missouri
    Posts
    66
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Does VBA have a Min() and Max() function? (Access/Word 2003)

    Maybe I'm thinking of another language, but I thought VBA has a Min() and Max () function. In jacking with some values in an Access module, I see this is not the case. Or at least, not with those names. Perhaps I was dreaming, but I swore such functions exist.

    I could create a function (since I only need to compare two values, I don't need to worry about passing a variable amount of arguments), but I thought I'd check out here to see if I am crazy.

    Kevin

  2. Subscribe to our Windows Secrets Newsletter - It's Free!

    Get our unique weekly Newsletter with tips and techniques, how to's and critical updates on Windows 7, Windows 8, Windows XP, Firefox, Internet Explorer, Google, etc. Join our 480,000 subscribers!

    Excel 2013: The Missing Manual

    + Get this BONUS — free!

    Get the most of Excel! Learn about new features, basics of creating a new spreadsheet and using the infamous Ribbon in the first chapter of Excel 2013: The Missing Manual - Subscribe and download Chapter 1 for free!

  3. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 16 Times in 16 Posts

    Re: Does VBA have a Min() and Max() function? (Access/Word 2003)

    Nope. MIN and MAX are worksheet functions in Excel, and Access has Min and Max in queries (and hence in SQL). But they are not general VBA functions.

  4. #3
    Super Moderator
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,507
    Thanks
    0
    Thanked 4 Times in 4 Posts

    Re: Does VBA have a Min() and Max() function? (Access/Word 2003)

    Strange, innit? From my archives, no error checking:

    Function maxoftwo(lng1 As Double, lng2 As Double) As Double
    maxoftwo = lng1
    If lng2 > lng1 Then maxoftwo = lng2
    End Function
    -John ... I float in liquid gardens
    [acronym title="Gday mate!"][/acronym] [acronym title="What up Dude?"][/acronym] UTC -7±DS

  5. #4
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Does VBA have a Min() and Max() function? (Access/Word 2003)

    Access does have DMin and DMax aggregate functions. Perhaps that's what you were thinking of.
    Charlotte

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •