+ Reply to Thread
Results 1 to 12 of 12

how to find last time word appears in column

  1. #1
    Forum Contributor
    Join Date
    11-14-2014
    Location
    uk
    MS-Off Ver
    Excel 2010
    Posts
    100

    how to find last time word appears in column

    I have imported the data from a log file into excel and now want to know if it is possible to find the last time the value i enter into cell A1 appears in column E and then display the numbers that appear in the cell 2 cells down in cell A2 ?

    thanks
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    12-13-2013
    Location
    Calgary,AB,Canada
    MS-Off Ver
    2016,O365
    Posts
    236

    Re: how to find last time word appears in column

    A2=INDEX(E:E,LOOKUP(9^9,ROW(E1:E10000)*1^FIND(A1,E1:E10000))+2)


    result is data in A211

  3. #3
    Forum Expert
    Join Date
    07-06-2004
    Location
    Northern California
    MS-Off Ver
    2K, 2003, 2010, O365
    Posts
    1,490

    Re: how to find last time word appears in column

    Quote Originally Posted by CAABYYC View Post
    A2=INDEX(E:E,LOOKUP(9^9,ROW(E1:E10000)*1^FIND(A1,E1:E10000))+2) . . .
    This makes the formula depend on all cells in col E, so it could recalculate a lot more often than necessary.

    An alternative,

    A2: =LOOKUP(1,0/(E1:E10000=A1),E3:E10002)

  4. #4
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    Win10/MSO2016
    Posts
    13,001

    Re: how to find last time word appears in column

    The formula:
    =LOOKUP(1,0/(E1:E10000=A1),E3:E10002)
    doesn't work. It has two problems

    a) that dividend must be 1 not zero
    b) "Exit Point" is only a part of the contents of the cell...

    It should be:
    {=LOOKUP(2,1/(FIND(A1,E1:E10000)),E3:E10002)}
    Ben Van Johnson

  5. #5
    Forum Expert
    Join Date
    07-06-2004
    Location
    Northern California
    MS-Off Ver
    2K, 2003, 2010, O365
    Posts
    1,490

    Re: how to find last time word appears in column

    Quote Originally Posted by protonLeah View Post
    . . . =LOOKUP(1,0/(E1:E10000=A1),E3:E10002)
    doesn't work. . . . It has two problems
    1st point is wrong. See this linked workbook. Download it and try it in several different Excel versions. For that matter, convert it to XLS format and try it in Excel 2003 or previous. FWIW, works for me in Excel 2000 and Excel in Office 365. For at least 2 decades, Excel's LOOKUP function has ignored errors in its lookup range/array when trying to bracket the value sought.

    2nd point may be apt, but should text searching be case-insensitive or not? IOW, FIND or SEARCH?

    ADDED: Note your recommended formula: =LOOKUP(2,1/(FIND(A1,E1:E10000)),E3:E10002)

    What value would FIND return when A1 doesn't appear in the values of cells in E1:E10000? Wouldn't that value be #VALUE! ? If so, wouldn't the array 1/(FIND(...)) [FWIW, redundant parentheses] return #VALUE! errors for those entries? Why would you believe LOOKUP would happily ignore #VALUE! errors but choke on #DIV/0! errors?
    Last edited by hrlngrv; 02-07-2020 at 01:28 AM.

  6. #6
    Forum Expert
    Join Date
    10-10-2016
    Location
    Sheffield
    MS-Off Ver
    365 and rarely 2016
    Posts
    3,212

    Re: how to find last time word appears in column

    An interesting debate. I think to a degree what does entering a value in a cell mean?
    1) Entire cell contents
    2) part of the cell contents

    Also for my knowledge I have used LOOKUP(1,1/(E1:E10000=A1),E3:E10002) which appears to work

    but what is the difference between this and LOOKUP(2,1/(E1:E10000=A1),E3:E10002)

    or indeed
    LOOKUP(1,0/(E1:E10000=A1),E3:E10002)

    They all seem to give the same results!

  7. #7
    Forum Contributor
    Join Date
    11-14-2014
    Location
    uk
    MS-Off Ver
    Excel 2010
    Posts
    100

    Re: how to find last time word appears in column

    =lookup(2,1/(find(a1,e1:e10000)),e3:e10002)

    this works great I would just like the ”‚ not to be in the output
    Last edited by semajjames; 02-07-2020 at 07:54 AM.

  8. #8
    Forum Contributor
    Join Date
    11-14-2014
    Location
    uk
    MS-Off Ver
    Excel 2010
    Posts
    100

    Re: how to find last time word appears in column

    the symbols are only present because the source log file contained so many random symbols I could not get rid of then during the import process

  9. #9
    Forum Expert
    Join Date
    07-06-2004
    Location
    Northern California
    MS-Off Ver
    2K, 2003, 2010, O365
    Posts
    1,490

    Re: how to find last time word appears in column

    Quote Originally Posted by davsth View Post
    . . . interesting debate. . . .
    Not a debate. This is an elementary software engineering exercise since the behavior (formula results) is easily checked and verified.

    . . . I have used LOOKUP(1,1/(E1:E10000=A1),E3:E10002) which appears to work . . .
    I believe I've had problems when the max value of LOOKUP's 2nd argument appears multiple times and equals its 1st argument. The behavior being exploited is bracketing values for binary search, and that's safest when the 1st argument is guaranteed larger than any value in the 2nd argument.

    . . . what is the difference between this and LOOKUP(2,1/(E1:E10000=A1),E3:E10002) or . . . LOOKUP(1,0/(E1:E10000=A1),E3:E10002) . . .
    Perhaps nothing. No difference between these last 2 formulas because the numeric 1st argument is guaranteed to be greater than any numeric value in the 2nd argument. I haven't done exhaustive testing of LOOKUP's 1st arg possibly = multiple max values from 2nd arg, but why take the chance it doesn't work when 1st arg guaranteed > any 2nd arg values is sure to work?
    Last edited by hrlngrv; 02-07-2020 at 05:17 PM.

  10. #10
    Forum Expert
    Join Date
    07-06-2004
    Location
    Northern California
    MS-Off Ver
    2K, 2003, 2010, O365
    Posts
    1,490

    Re: how to find last time word appears in column

    Quote Originally Posted by semajjames View Post
    . . . I would just like the ”‚ not to be in the output
    If you want the numbers as numeric values,

    =--REPLACE(LOOKUP(1,0/FIND(A1,E25:E75),E27:E77),1,2,"")

  11. #11
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: how to find last time word appears in column

    Assuming:
    1. We're looking for a numeric answer,
    2. that there's the possibility of negative numbers,
    3. the characters always appear before the number.

    Formula: copy to clipboard
    Please Login or Register  to view this content.

    or use LOOKUP(2,1/.... either works. Also, only OP knows if SEARCH or FIND is more appropriate for his situation.
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  12. #12
    Forum Contributor
    Join Date
    11-14-2014
    Location
    uk
    MS-Off Ver
    Excel 2010
    Posts
    100

    Re: how to find last time word appears in column

    Thanks for taking the time to look at this guys.

    I have updated the test file and changed the code to try and show you guys what i am wanting to happen,
    you will see that i am trying to include the whole column because the log file being used can at times contain many rows
    also i have added the cell A3 to show how i need this to work with letters and numbers.
    when making these changes to the code it stopped working.
    Attached Files Attached Files

+ 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] if word appears in column b within date range in column q.
    By Shaunlea in forum Excel Formulas & Functions
    Replies: 13
    Last Post: 04-08-2016, 10:48 AM
  2. [SOLVED] Find word and if number appears below word then copy
    By ScabbyDog in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 01-14-2016, 11:12 AM
  3. [SOLVED] find a total of times a word appears across all the sheets in column "C"
    By NickB79 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-20-2013, 10:28 AM
  4. [SOLVED] Need to Calculate How Many Times Word Appears in Column
    By kthrynileen in forum Excel General
    Replies: 3
    Last Post: 09-15-2012, 07:41 PM
  5. [SOLVED] Count how many times certain word appears in column
    By micko_escalade in forum Excel General
    Replies: 4
    Last Post: 08-16-2012, 07:55 PM
  6. Replies: 3
    Last Post: 01-11-2012, 06:46 PM
  7. Replies: 5
    Last Post: 04-16-2005, 11:07 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