+ Reply to Thread
Results 1 to 6 of 6

Find the lowest integer in an array

  1. #1
    Registered User
    Join Date
    06-21-2012
    Location
    Tolland, CT
    MS-Off Ver
    Excel 2007
    Posts
    37

    Find the lowest integer in an array

    I have an array of integers and i want to test for the smallest value in sections of the array. In other words if i have an array:

    value(14) As Integer, r As Integer

    'Code that sets array values

    r = int (5 * rnd)

    'find the lowest between:

    value(r * 3 - 3) and value(r * 3)

    'lowest value(n)

    'return n


    I already have the code to set the array values. I just need to find the array member with the lowest integer, not the integer itself.

    Thanks in advance. Sorry if this is kind of a strange one!

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Find the lowest integer in an array

    Hello publius190,

    This example should help. You can use either a Range or an Array, It will return the index number that holds the minimum value.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    06-21-2012
    Location
    Tolland, CT
    MS-Off Ver
    Excel 2007
    Posts
    37

    Re: Find the lowest integer in an array

    So doing it with ranges will find the lowest range in the array? like the smallest amount of cells?

  4. #4
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Find the lowest integer in an array

    Hi publius190,

    I thought about this problem yesterday and realized there are lots of kinds of arrays. There are single dimension and double dimension arrays. Arrays can be horizontal or vertical, when looking at them in Excel. If you were to know the 7th position in an array contained the smallest value this wouldn't be enough. You'd also need to know where the array started and/or ended. How about the (3,4) position in the array? All this can be done with VBA but I'm clueless on how you need to apply this information. See the attached for some more questions about your thread.
    Attached Files Attached Files
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  5. #5
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Find the lowest integer in an array

    Hello publius190,

    A range is a 2-D array. The macro will return the lowest number found within the range the same as it will with a declared array. Here is the macro rewritten to examine a range for the lowest value and return the row of the cell.
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    06-21-2012
    Location
    Tolland, CT
    MS-Off Ver
    Excel 2007
    Posts
    37

    Re: Find the lowest integer in an array

    OK thanks everyone. Finding the range with the minimum value worked perfectly.

+ 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