Finding Cell with Minimum/Maximum Value in Active Worksheet

Let say we want to find position of cell containing the minimum/maximum value in current/active Excel worksheet, and then after we found the cell, we will change the cell format to make it stand out before other cells.

The logic is simple, we just need to use Excel MIN function to find the minimum/maximum value on the worksheet, and then using Excel FIND function we will find which cell contain that minimum/ maximum value.

Excel VBA macro implementation of the algorithm above will look like below, change code Application.Min(oRg) into Application.Max(oRg) to find the maximum value instead of minimum value.

Sub FindMinValue()

    Dim oRg As Range, iMin As Variant

    Set oRg = Cells
    'Finding the minimum value
    'change Application.Min(oRg) into Application.Max(oRg) to find the maximum value
    iMin = Application.Min(oRg)

    'Select cell containing the min value
    oRg.Find(What:=iMin, _
        After:=oRg.Range("A1"), _
        LookIn:=xlValues, _
        LookAt:=xlPart, _
        SearchOrder:=xlByRows, _
        SearchDirection:=xlNext, MatchCase:=False _
        ).Select

    'Change selected cell format
    With Selection.Interior
        .Pattern = xlSolid
        .PatternColorIndex = xlAutomatic
        .ThemeColor = xlThemeColorAccent3
        .TintAndShade = 0
        .PatternTintAndShade = 0
    End With

    'Displaying min value info
    With Selection
        MsgBox "Min value : " & iMin & vbCrLf & _
        "Cell position " & vbCrLf & _
        "Row : " & .Row & vbCrLf & _
        "Column : " & .Column
    End With

End Sub

As an additional info, the code above will display the cell info, row and column position of the cell containing the minimum/maximum value.

This entry was posted in Excel VBA Function, Workbook and Worksheet and tagged , , , , , , , , , , , , , , , , , , . Bookmark the permalink.

1,062 Responses to Finding Cell with Minimum/Maximum Value in Active Worksheet

  1. Paul says:

    Once more, the Internet saves me !
    I was having the same problem, googled it, solved it, all in 3 minutes, thanks to all the good folks who raise questions, and the even better souls who answer them on forums.

    Thanks a lot everyone

  2. NewToVBA says:

    This really helped! Thanks a ton for this!

  3. Jenn says:

    Hello there,
    When I run this code, I get Runtime Error 91 (object variable or with variable not set) and when I debug it refers to the Find function.
    Does anyone know what might cause this?

  4. Poer says:

    Hi Jenn, maybe not the Find function that wasn’t set, but oRg object. Did you already set the oRg range object with “Set oRg = Cells” like in line 5?

  5. Pingback: M?nimo de un rango de celdas - Ayuda Excel

  6. Pingback: Angry Birds Online

  7. Pingback: reverse mortgages calculator

  8. Pingback: Alternative Energy Projects

  9. Pingback: walmart credit card

  10. Pingback: debt collection agency

  11. Pingback: Wedding photographer services calgary

  12. Pingback: collection agency rates

  13. Pingback: film x

  14. Pingback: best bread machine

  15. Pingback: rapidrecoverysolution.com

  16. Pingback: collection agency newsletter

  17. Pingback: uverse coupon,uverse deals, att uverse coupon,uverse coupon code internet

  18. Pingback: vimax

  19. Pingback: wedding photographer calgary

  20. Pingback: buikspieroefeningen

  21. Pingback: stretcher

  22. Pingback: juegos de ben 10

  23. Pingback: patio table umbrellas

  24. Pingback: Tucson Assisted Living

  25. Pingback: ???? ???????????

  26. Pingback: hier

  27. Pingback: Quality Backlinks

  28. Pingback: ????????????? ???

  29. Pingback: best buy coupon codes

  30. Pingback: Scrapeboard

  31. Pingback: ???????? xis

  32. Pingback: free ipad 2

  33. Pingback: window shutters

  34. Pingback: jualan online

  35. Pingback: tricksterzz

  36. Pingback: coupons for laundry detergent

  37. Pingback: Marijuana Graines À Autofloraison

  38. Pingback: fapturbo reviews

  39. Pingback: ????? ??????

  40. Pingback: ????? ??????

  41. Pingback: Collection Agency Laws

  42. Pingback: pay per click

  43. Pingback: Vippi pankkitunnuksilla

  44. Pingback: http://freecreditreportz.com

  45. Pingback: europeana portal

  46. Pingback: how to get a free credit report

  47. Pingback: Cityville hack

  48. Pingback: is a used car warranty worth it

  49. Pingback: Document Solutions

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>