+ Reply to Thread
Results 1 to 5 of 5

Min. function question

  1. #1
    Registered User
    Join Date
    01-12-2005
    Posts
    1

    Min. function question

    Is there a way to return a min. number great than zero from a row?

    For instance
    A, B,C, D, E, F, G
    0,-1,2, 4, 7, -2 2

    I want to see "2" on the column G.

    Thanks

  2. #2
    Forum Contributor
    Join Date
    11-09-2004
    Posts
    451
    you can use this function, in g1 cell copy =min_g_zero(a1:f1) and drag the cell down


    you have the paste this function by creating a module in visual basic editor,

    go to->tools->macro->visual basic editor , select "microsoft excel objects" , right click-> insert module and then in the editor space paste the below code.



    Function min_g_zero(d As Range)
    Dim k As Integer
    Dim val As Variant
    k = 0
    val = "-1"
    For Each c In d
    If c > 0 Then
    If k = 0 Then
    val = c
    Else
    If c < val Then
    val = c
    End If
    End If
    k = k + 1
    End If

    Next
    If val = -1 Then
    min_g_zero = "no cells are greater than zero "
    Else
    min_g_zero = val
    End If
    End Function

  3. #3
    Forum Expert
    Join Date
    12-24-2004
    Location
    Sweden
    Posts
    1,256
    Or if you want a formula:
    =MIN(IF(A1:G1>0;A1:G1;""))

    Ola Sandstrom


    Hold down Ctrl and Shift then hit Enter to confirm the formula.

  4. #4
    Forum Contributor
    Join Date
    11-09-2004
    Posts
    451
    It is giving me error when I use that function. I was trying to correct it, but not able to correct it.

  5. #5
    Forum Expert
    Join Date
    12-24-2004
    Location
    Sweden
    Posts
    1,256
    It should work if it's Entered as an Array formula - Hold down Ctrl and Shift then hit Enter to confirm the formula. Othervise you will get #VALUE!

+ 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