+ Reply to Thread
Results 1 to 3 of 3

Thread: Look for a value in previous ranges and display row difference

  1. #1
    Valued Forum Contributor sans's Avatar
    Join Date
    10-19-2011
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    327

    Look for a value in previous ranges and display row difference

    Hello,

    I'd like to check a value against previous ranges, find the first occurence and receive the row difference.

    For example,

    34 35 45 56 57 64 65
    16 23 36 38 56 65 70
    25 27 37 54 60 66 68
    12 32 38 47 52 57 70
    18 25 37 39 50 51 54
    23 20 21 22 58 59 62
    25 37 22 56 64 57 59

    Checking the last range, the result for number 25 is 2 as number 25 appears two rows before.

    So the result for all the values in the last range is

    2 2 1 5 6 3 1


    I have been trying to get this formula to work

    =IFERROR(ROW()-LOOKUP(2,1/($O$1:$O4927=$O4928),ROW($B$1:$B4927)),ROW()))

    which I have from another member here on the forum which looks for a value in one column only and returns the row difference. I have tried changing the formula to

    =IFERROR(ROW()-LOOKUP(2,1/($O$1:$U4927=$O4928),ROW($A$1:$A4927)),ROW()))

    but I get an incorrect result.


    Thank you,
    Sans
    Last edited by sans; 11-24-2011 at 10:53 AM.

  2. #2
    Forum Guru NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    32,636

    Re: Look for a value in previous ranges and display row difference

    You are working on some interesting project..

    Try:

    =ROW($O4928)-MAX(($O$1:$O4927=$O4928)*ROW($O$1:$O4927))

    confirmed with CTRL+SHIFT+ENTER not just ENTER and copied across.
    Microsoft MVP - Excel

    Where there is a will there are many ways. Pick One!


    Please read the Forum Rules

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

    Preferred Charities: Lupus Canada and Sick Kids Foundation.
    Feel Free to Donate if you want to, for the assistance you received today.

  3. #3
    Valued Forum Contributor sans's Avatar
    Join Date
    10-19-2011
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    327

    Re: Look for a value in previous ranges and display row difference

    Hi NBVC,

    It works great! Thank you very much. Yes, it is a very interesting project, actually they are many small projects, but they take a lot of time to analyse manually (and as you can see, often with mistakes, in my case ) . This was the main reason I started using excel, which I now have found useful in so many ways.

    Thank you again for your help,
    Sans

+ 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.2.0