+ Reply to Thread
Results 1 to 5 of 5

problem with offset to find the nearest string

  1. #1
    Forum Contributor
    Join Date
    12-23-2007
    Location
    chennai india
    MS-Off Ver
    2010
    Posts
    141

    problem with offset to find the nearest string

    my formula in offset chooses the first occurance while I want the last occurance.

    thanks in advance
    Attached Files Attached Files

  2. #2
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: problem with offset to find the nearest string

    Using your posted workbook...
    I'm guessing that there are more parameters, but for what you've described, try this formula.
    Please Login or Register  to view this content.
    Is that something you can work with?
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  3. #3
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: problem with offset to find the nearest string

    @ Ron Coderre:

    Am I correct in thinking that if there were more than two entries that start with "m/s" that the "lookup(2, would have to be increased to something larger than the possible number of occurrences of "m/s" in order to get the last entry?
    <---------If you like someone's answer, click the star to the left of one of their posts to give them a reputation point for that answer.
    Ron W

  4. #4
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: problem with offset to find the nearest string

    Actually, no...
    In the formula I posted: =IFERROR(LOOKUP(2,1/(LEFT($B$2:$B$13,3)="m/s"),$B$2:$B$13),"no match")

    This section: 1/(LEFT($B$2:$B$13,3)="m/s")
    returns an array of 1's (for matched items) and #DIV/0!'s (for non-matching items)

    Since the LOOKUP is searching for a 2...which is larger than any of the array values (which have a max of 1)...it will match on the last numeric data.
    That last numeric value will be the last matched item.

    Experiment with it.

    Does that help?

  5. #5
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: problem with offset to find the nearest string

    @ Ron Coderre:

    Thanks for the explanation. I did a bit of experimenting, adding additional "m/s" values in the column and highlighting the section in the formula and hitting F9 to show the result of that part of the formula, could very well see what you explained.

    Thank you.

+ 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 certain string and offset the cell in filtered data
    By orangeballoons in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-25-2013, 12:10 AM
  2. [SOLVED] problem finding string using .find method when string to be found contains ~ (a tilde)
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-01-2013, 07:38 AM
  3. Problem with Selection find, offset, copy & paste Macro
    By MDResearcher in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 06-21-2011, 05:51 PM
  4. Find string and offset copy
    By EnergyEngineer in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-28-2007, 05:06 PM
  5. Find string, offset one column, enter string
    By mikellyrice in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-29-2007, 02:06 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