+ Reply to Thread
Results 1 to 7 of 7

Finding First and Last column of cell based on other cell

  1. #1
    Registered User
    Join Date
    11-27-2014
    Location
    Patiala
    MS-Off Ver
    Microsoft office 2007
    Posts
    2

    Finding First and Last column of cell based on other cell

    I have the following data
    A B
    x ram
    x sham
    x mohan
    y garry
    y tom
    y marry
    z john
    z sandhu
    z sanday

    Now I want first and last value of x i.e. ram and mohan in column C and D
    Similary first and last value of y garry and marry
    and so on

    Can Any one tell me how to do it.


    Vinod
    Last edited by vinod_nir71; 08-03-2015 at 06:14 AM.

  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
    44,150

    Re: Finding First and Last column of cell based on other cell

    Like this:

    For the first match:
    =INDEX($B$1:$B$11,MATCH(C1,$A$1:$A$11,0))

    For the last match:
    =IFERROR(LOOKUP(2,1/($A$1:$A$11=C1),$B$1:$B$11),"")

    drag down.
    Attached Files Attached Files
    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

  3. #3
    Forum Expert
    Join Date
    12-11-2011
    Location
    Netherlands
    MS-Off Ver
    office 365
    Posts
    3,323

    Re: Finding First and Last column of cell based on other cell

    Or maybe this?
    Attached Files Attached Files
    Willem
    English is not my native language sorry for errors
    Please correct me if I'm completely wrong

  4. #4
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Finding First and Last column of cell based on other cell

    @popipipo

    Sorry for the off-topic interjection:

    Although there is no official rule regarding this behaviour, we request that wherever possible both the question AND the answer be provided in substantive detail here within the thread.

    An attached workbook is an excellent aid for posing a question and offering a solution, but solely doing that with no in-thread explanation makes it difficult for researchers to understand or consider the Q & A of this thread without downloading what may be a pointless doc to them, if they can do that at all. Doing that also hides the content from search engines so others may never benefit from this.

    I'm sure you understand, and we look forward to seeing you post your formulas/macros in your posts for the searching benefit of all.

    Regards
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  5. #5
    Forum Expert
    Join Date
    12-11-2011
    Location
    Netherlands
    MS-Off Ver
    office 365
    Posts
    3,323

    Re: Finding First and Last column of cell based on other cell

    @XOR LX
    Sorry for doing it this way
    I freqently give such answers and nobody ever told me this.

    The formulas i gave in the files are:

    First match: =VLOOKUP(G1,A1:B11,2,0)
    Last match: =VLOOKUP(G1,A1:B11,2,1)

  6. #6
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,914

    Re: Finding First and Last column of cell based on other cell

    Quote Originally Posted by popipipo View Post
    @XOR LX
    Sorry for doing it this way
    I freqently give such answers and nobody ever told me this.

    The formulas i gave in the files are:

    First match: =VLOOKUP(G1,A1:B11,2,0)
    Last match: =VLOOKUP(G1,A1:B11,2,1)
    Last match: =VLOOKUP(G1,A1:B11,2,1) will not give correct result if the Column A is not in ascending order
    Samba

    Say thanks to those who have helped you by clicking Add Reputation star.

  7. #7
    Forum Contributor
    Join Date
    06-14-2013
    Location
    jk
    MS-Off Ver
    Excel 2007
    Posts
    326

    Re: Finding First and Last column of cell based on other cell

    In cell C2:

    =IF(A2=A3,"",B2)

    In cell D2:

    =IF(A2=A1,"",B2)

    Drag the formula down over the complete range.
    Would this work for 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. [SOLVED] Selecting a Cell in column "A", and finding where / If the cell exists in column D
    By AMWalton89 in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 09-18-2014, 11:22 AM
  2. Macro to change colour of cell based on finding a specific word in the cell
    By Shelby761 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-24-2014, 09:46 AM
  3. [SOLVED] Set cell equal to variable cell (from set column) based on cells in adjacent column
    By alter54 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-24-2014, 01:04 PM
  4. Finding a cell based in a search for another cell
    By dellam in forum Excel General
    Replies: 5
    Last Post: 10-29-2013, 12:08 PM
  5. Finding the last cell in a column based on cell contents
    By carlito_1985 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-14-2011, 05:06 AM
  6. finding the value of a cell based on another cell
    By jt1561 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-17-2010, 05:00 PM
  7. [SOLVED] Finding Cell Interior Colour of First Cell in Column
    By ExcelMonkey in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-21-2005, 11: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