+ Reply to Thread
Results 1 to 18 of 18

Find distance between Max to Min values in array?

  1. #1
    Forum Contributor
    Join Date
    08-18-2017
    Location
    London
    MS-Off Ver
    Excel 2016
    Posts
    308

    Find distance between Max to Min values in array?

    hi excelers,
    How do I find the distance between Max to Min values in array?
    bit complex to write so here's a simple example:

    1
    2
    3
    4
    5
    = 3
    (cuz the distance between 1 (Min number) and 5 (Max number) is array cells 3

    another example

    6
    11
    4
    3
    8
    = 1
    (cuz the distance between 3 (Min number) and 11 (Max number) in array cells is 1

    thx for any suggestions and please keep your solution as short & simple as possible*

  2. #2
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: Find distance between Max to Min values in array?

    Maybe:

    =MATCH(MAX($A$1:$A$5),$A$1:$A$5,0)-MATCH(MIN($A$1:$A$5),$A$1:$A$5,0)-1
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  3. #3
    Registered User
    Join Date
    07-18-2018
    Location
    Bella, Kafr El Sheikh, Egypt
    MS-Off Ver
    16.0
    Posts
    6

    Re: Find distance between Max to Min values in array?

    Assuming that the numbers in cells A1 up to A5
    Use the following formula:

    Please Login or Register  to view this content.

  4. #4
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,811

    Re: Find distance between Max to Min values in array?

    Probably need an ABS() function as part of that, because it seems that you won't know in advance whether MAX() or MIN() will be earlier/later in the array. ABS(position of max-position of min)-1

    Edit to add -- unless you want the sign of the distance to indicate direction? but your example does not show an interest in direction, so I would guess not.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  5. #5
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: Find distance between Max to Min values in array?

    Thank you, Sir!!!


    =ABS(MATCH(MAX($A$1:$A$5),$A$1:$A$5,0)-MATCH(MIN($A$1:$A$5),$A$1:$A$5,0))-1

  6. #6
    Forum Contributor
    Join Date
    08-18-2017
    Location
    London
    MS-Off Ver
    Excel 2016
    Posts
    308

    Re: Find distance between Max to Min values in array?

    nice to both of you...but is it possible to fit a Index function into this formula as so I can control the array window to calculate?

  7. #7
    Forum Contributor
    Join Date
    08-18-2017
    Location
    London
    MS-Off Ver
    Excel 2016
    Posts
    308

    Re: Find distance between Max to Min values in array?

    first suggestion gets a star *)

  8. #8
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: Find distance between Max to Min values in array?

    Why not just use a named range?

  9. #9
    Forum Contributor
    Join Date
    08-18-2017
    Location
    London
    MS-Off Ver
    Excel 2016
    Posts
    308

    Re: Find distance between Max to Min values in array?

    cuz I need to dynamically change it!

  10. #10
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,811

    Re: Find distance between Max to Min values in array?

    Named ranges can be dynamic (usually using the OFFSET() function rather than INDEX()): https://www.excel-easy.com/examples/...med-range.html

  11. #11
    Forum Contributor
    Join Date
    08-18-2017
    Location
    London
    MS-Off Ver
    Excel 2016
    Posts
    308

    Re: Find distance between Max to Min values in array?

    thx shorty, but how is it connected/worked-into this formula:
    =ABS(MATCH(MAX($A$1:$A$5),$A$1:$A$5,0)-MATCH(MIN($A$1:$A$5),$A$1:$A$5,0))-1

  12. #12
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,811

    Re: Find distance between Max to Min values in array?

    Replace the "$A$1:$A$5" references with your dynamic named range (or an OFFSET() function, if you don't want to define a named range).
    1) define named range "mynamedrange" as =OFFSET(something). You have not described the exact logic you are using to dynamically define the range, so I cannot make a specific suggestion. If you are unfamiliar with the OFFSET() function: https://support.office.com/en-us/art...e-b4d906d11b66

    2) Replace the $A$1:$A$5 references in the above function with "mynamedrange". Using the MAX() function part as an example =...MAX(mynamedrange)...

    3) Or, if you don't want to define a named range, simply replace the $A$1:$A$5 references with your OFFSET() function. Again, using the MAX() part of the function as the example. =...MAX(OFFSET(logic_needed_to_define_range))...

  13. #13
    Forum Contributor
    Join Date
    08-18-2017
    Location
    London
    MS-Off Ver
    Excel 2016
    Posts
    308

    Re: Find distance between Max to Min values in array?

    Hi Shorty,
    being at it for hours now...I was unable to recreate the formula with your offset solution!
    to explain it better I create a example sheet for you please check it out. thx
    Attached Files Attached Files
    Last edited by QuantEdge; 09-23-2018 at 06:26 AM.

  14. #14
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: Find distance between Max to Min values in array?

    This named range (List):
    =Sheet1!$A$1:INDEX(Sheet1!$A:$A,MATCH(1E+100,Sheet1!$A:$A))

    with the modified formula:
    =ABS(MATCH(MAX(List),List,0)-MATCH(MIN(List),List,0))-1

    will extend as far as is needed to cope with the length of your data column...
    Attached Files Attached Files

  15. #15
    Forum Contributor
    Join Date
    08-18-2017
    Location
    London
    MS-Off Ver
    Excel 2016
    Posts
    308

    Re: Find distance between Max to Min values in array?

    I tried to add it to my sheet but still does not work! what am I doing worry?
    Attached Files Attached Files

  16. #16
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,577

    Re: Find distance between Max to Min values in array?

    Try this
    =ABS(MATCH(MAX(OFFSET($A$1,0,0,$B$1)),OFFSET($A$1,0,0,$B$1),0)-MATCH(MIN(OFFSET($A$1,0,0,$B$1)),OFFSET($A$1,0,0,$B$1),0))-1
    Attached Files Attached Files
    Last edited by kvsrinivasamurthy; 09-23-2018 at 09:34 AM.
    Pl note
    Array formula should be confirmed with Ctrl+Shift+Enter keys together.
    If answere is satisfactory press * to add reputation.

  17. #17
    Forum Contributor
    Join Date
    08-18-2017
    Location
    London
    MS-Off Ver
    Excel 2016
    Posts
    308

    Re: Find distance between Max to Min values in array?

    th kvsrinivasamurthy , that works beautifully stars for u)
    Last edited by QuantEdge; 09-23-2018 at 11:36 AM.

  18. #18
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,577

    Re: Find distance between Max to Min values in array?

    Thanks for the compliment.

+ 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. [SOLVED] How to Use array match function in a distance matrix
    By muddit0 in forum Excel Formulas & Functions
    Replies: 22
    Last Post: 03-21-2018, 12:01 PM
  2. Replies: 13
    Last Post: 10-08-2014, 08:35 AM
  3. Replies: 3
    Last Post: 05-25-2012, 03:16 AM
  4. Find a value in an array and return multiple values in an adjacent array
    By tonbra in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-02-2012, 08:35 PM
  5. Find the top 3 values of an array
    By alphecca in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 04-21-2011, 02:56 PM
  6. Loop/Array to Determine average distance traveled
    By Kwagga in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-17-2008, 05:19 AM
  7. help with distance array
    By grime in forum Excel General
    Replies: 4
    Last Post: 09-30-2005, 01:19 PM

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