+ Reply to Thread
Results 1 to 8 of 8

Find previous occurance

  1. #1
    Registered User
    Join Date
    11-02-2012
    Location
    London, England
    MS-Off Ver
    Office 365 / 16
    Posts
    9

    Find previous occurance

    Hi I have a list of string values in column D on a sheet. I need to get a formula in column J which looks at the string in Column D and then searches back up column D to find the same string. Once found it should return the value on that row of column F. If it doesn't find anything then just enter a 0. If tried match, index but maybe wrongly. I really dont want to use VBA as this will be sent around the office and this then causes problems with others setups

  2. #2
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Find previous occurance

    Can you post some sample data and tell us what result you expect?
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  3. #3
    Registered User
    Join Date
    11-02-2012
    Location
    London, England
    MS-Off Ver
    Office 365 / 16
    Posts
    9

    Re: Find previous occurance

    Yeah

    D F J
    1 Cat 1000 0
    2 Cat 20 1000
    3 Dog 15 0
    4 Dog 10000 15
    5 Cat 500 20
    6 Dog 1 10000

    So Column J takes the string from column D and then searches for the previous instance. it then looks at the value in column F of that instance and returns it

    Does that make sense????

  4. #4
    Registered User
    Join Date
    11-02-2012
    Location
    London, England
    MS-Off Ver
    Office 365 / 16
    Posts
    9

    Re: Find previous occurance

    Sorry formatting want odd. Will try to make it clearer

  5. #5
    Registered User
    Join Date
    11-02-2012
    Location
    London, England
    MS-Off Ver
    Office 365 / 16
    Posts
    9

    Re: Find previous occurance

    Capture.JPG

    Here this is better

  6. #6
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Find previous occurance

    Try this...

    Data Range
    D
    F
    J
    1
    2
    Cat
    1000
    0
    3
    Cat
    20
    1000
    4
    Dog
    15
    0
    5
    Dog
    10000
    15
    6
    Cat
    500
    20
    7
    Dog
    1
    10000
    8
    ------
    ------
    ------


    This array formula** entered in J2 and copied down:

    =IF(MATCH(D2,D:D,0)=ROW(),0,INDEX(F:F,SMALL(IF(D$2:D$7=D2,ROW(D$2:D$7)),COUNTIF(D$2:D2,D2)-1)))

    ** array formulas need to be entered using the key
    combination of CTRL,SHIFT,ENTER (not just ENTER).
    Hold down both the CTRL key and the SHIFT key
    then hit ENTER.

  7. #7
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2021
    Posts
    5,957

    Re: Find previous occurance

    Try this in J2:

    =IF(COUNTIF($D$1:D1,D2)=0,0,LOOKUP(2,1/($D$1:D1=D2),$F$1:F1))

  8. #8
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2405
    Posts
    13,422

    Re: Find previous occurance

    Another way. In J2 (this cannot start in row 1). Array entered also.
    Formula: copy to clipboard
    Please Login or Register  to view this content.




    Row\Col
    D
    F
    J
    1
    2
    Cat
    1000
    0
    3
    Cat
    500
    1000
    4
    Cat
    365
    500
    5
    Dog
    456
    0
    6
    Dog
    987
    456
    7
    Cat
    123
    365
    8
    Dog
    951
    987
    Dave

+ 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. Find Min Date for occurance of value
    By gammaman in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-25-2015, 10:42 PM
  2. [SOLVED] Find certain word, copy and paste cell in previous row if previous row is blank
    By steven_e in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-19-2013, 12:53 PM
  3. [SOLVED] Find last previous non blank value and summarise previous 6 months
    By Lady_Shaz in forum Excel General
    Replies: 7
    Last Post: 12-11-2012, 06:20 AM
  4. Replies: 3
    Last Post: 04-05-2011, 04:56 AM
  5. Replies: 1
    Last Post: 07-30-2009, 05:54 AM
  6. Finding and subtracting previous occurance of date
    By iLurk in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-24-2009, 04:51 PM
  7. [SOLVED] Find next occurance
    By Jambruins in forum Excel General
    Replies: 5
    Last Post: 08-10-2006, 11: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