+ Reply to Thread
Results 1 to 5 of 5

Find max and min value in range of cells using VBA

  1. #1
    Forum Contributor
    Join Date
    11-17-2009
    Location
    PA USA
    MS-Off Ver
    Excel 2000
    Posts
    184

    Find max and min value in range of cells using VBA

    I have this formula in Excel:

    Please Login or Register  to view this content.
    I need to move this to VBA code for other reasons. Is there a similar command or routine in VBA to find the max and min values of a range of cells?

    Thank you for helping me.

    Excel 2000
    Last edited by proepert; 06-07-2010 at 10:10 AM.

  2. #2
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Find max and min value in range of cells using VBA

    Try

    Please Login or Register  to view this content.

    Hope this helps.

    If you need any further information, please feel free to ask further

    However

    If this takes care of your needs, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED. It helps everybody!
    Also
    If you are satisfied by any members response to your problem please consider using the scales icon top right of thier post to show your appreciation.
    Last edited by Marcol; 06-06-2010 at 10:24 PM.

  3. #3
    Forum Contributor
    Join Date
    11-17-2009
    Location
    PA USA
    MS-Off Ver
    Excel 2000
    Posts
    184

    Re: Find max and min value in range of cells using VBA

    Thank you.

    How can the code ignore zero values when calculating the MIN.

    Okay, so it's not really the MIN, it's the MIN value greater than zero.

  4. #4
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Find max and min value in range of cells using VBA

    Try this

    Please Login or Register  to view this content.

    This can be used as a UDF if you want, but your Excel function runs in a macro free workbook, obviously, by definition, UDFs can't. Many companies don't allow macros.

    =maxmin(E19:E40)

    The macro "MaxMinusMinIgnoreZeros" calls the function in VBa

    I have attached a demo workbook.

    Hope this helps.

    If you need any further information, please feel free to ask further

    However

    If this takes care of your needs, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED. It helps everybody!
    Also
    If you are satisfied by any members response to your problem please consider using the scales icon top right of thier post to show your appreciation.
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    11-17-2009
    Location
    PA USA
    MS-Off Ver
    Excel 2000
    Posts
    184

    Re: Find max and min value in range of cells using VBA

    Thank you very much.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1