+ Reply to Thread
Results 1 to 7 of 7

writing user defined minimum value function

  1. #1
    Registered User
    Join Date
    01-25-2015
    Location
    india
    MS-Off Ver
    2007
    Posts
    10

    writing user defined minimum value function

    Hi, can you help me by providing user defined minimum value function from a range of values, without using Excel min formula in vba

  2. #2
    Forum Contributor
    Join Date
    01-14-2014
    Location
    London, England
    MS-Off Ver
    Excel 2013
    Posts
    240

    Re: writing user defined minimum value function

    You might have to be more specific - not sure why you wouldn't just use Min? There are various ways to do this mainly various different types of sort. A bubblesort springs to mind but that is long and difficult.
    Please consider adding a * if I helped.

  3. #3
    Registered User
    Join Date
    01-25-2015
    Location
    india
    MS-Off Ver
    2007
    Posts
    10

    Re: writing user defined minimum value function

    Hi Brendan

    Why I am asking specifically is, I was trying to write other custom function like sum, count if and others normally, and hot stuck on this function for a range of cells more than 2.

    Will you hel me giving simple code/idea how can I get minimum value from a selected range of cells.

  4. #4
    Forum Contributor
    Join Date
    01-14-2014
    Location
    London, England
    MS-Off Ver
    Excel 2013
    Posts
    240

    Re: writing user defined minimum value function

    Suck the data in to an array then do something like this:

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    01-25-2015
    Location
    india
    MS-Off Ver
    2007
    Posts
    10

    Re: writing user defined minimum value function

    Hey thanks.

    I am not thought of using array. Is the code can be written to loop through each cell in range selected and give min value. I want this code to be simple.

    Forgot to mention, If a cell has '0' in a range selected then min value will be 0. So that cell has to be ignored and min Val should be from all cells in range.

  6. #6
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: writing user defined minimum value function

    You could use this. MinNonZeroValue will accept up to 29 arguments. An argument can be any value or a range or an array.

    Please Login or Register  to view this content.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  7. #7
    Registered User
    Join Date
    01-25-2015
    Location
    india
    MS-Off Ver
    2007
    Posts
    10

    Re: writing user defined minimum value function

    Hi,

    ok, i have written below code to find min value in a range. But i am not getting any results for this function created.

    Function Getmin(MinRange As Range)
    Dim Counter As Integer
    Dim Sminval As Integer
    Dim TempMin As Integer

    Counter = 1
    For Each cell In MinRange
    If IsNumeric(cell.Value) = True And IsNull(cell.Value) = False Then
    If Sminval < cell.Value Then
    TempMin = Sminval
    End If
    End If
    Counter = Counter + 1
    Next
    Getmin = TempMin

    End Function

    can you help me in correcting this function code.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 1
    Last Post: 05-08-2014, 04:57 AM
  2. [SOLVED] User defined function returns an error on a standard function used in it.
    By pb48 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-23-2013, 01:35 PM
  3. [SOLVED] Excel - User Defined Function Error: This function takes no argume
    By BruceInCalgary in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-18-2006, 04:05 PM
  4. Writing macro results to user defined areas within excel
    By gauss1976 in forum Excel General
    Replies: 1
    Last Post: 07-27-2006, 08:40 AM
  5. Replies: 0
    Last Post: 06-20-2006, 10:55 AM

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