+ Reply to Thread
Results 1 to 10 of 10

formula to show first and last row results based on creteria

  1. #1
    Forum Contributor
    Join Date
    03-17-2013
    Location
    USA, IL
    MS-Off Ver
    Excel 2010
    Posts
    121

    formula to show first and last row results based on creteria

    Hi,

    I am pretty sure there is a way but I have been struggling with this tonight. Is there a formula that can show the first value/text that appears in a row based on a criteria and a separate formula that shows the last value/text in a row based on the same criteria?

    As an example if column A had "Apples" from A1:A5 and column B1:B5 had the color type of the Apples, I was hoping the formula can display the first color in B1 and the last color in B5.

    Thanks.
    Pi*

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,169

    Re: formula to show first and last row results based on creteria

    Hi Pi*,

    It sounds like you are looking for those Lookup() functions. I think there was a thread asking the same question at:

    https://www.excelforum.com/excel-for...d2-b2-b10.html

    See if it helps answer your question. BTW - If you supply a sample workbook it is much easier to understand your question and come up with an answer.

    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Valued Forum Contributor
    Join Date
    10-29-2012
    Location
    Mojokerto,Indonesia
    MS-Off Ver
    Excel 2007
    Posts
    554

    Re: formula to show first and last row results based on creteria

    to know the first color (array formula)
    =INDEX($B$1:$B$5,MIN(IF($A$1:$A$5="aple",ROW($A$1:$A$5))))

    to know the last color (array formula)
    =INDEX($B$1:$B$5,MAX(IF($A$1:$A$5="aple",ROW($A$1:$A$5))))

  4. #4
    Forum Contributor
    Join Date
    03-17-2013
    Location
    USA, IL
    MS-Off Ver
    Excel 2010
    Posts
    121

    Re: formula to show first and last row results based on creteria

    I appreciate the feedback. I have attached a sample file showing the results I am anticipating...
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    03-17-2013
    Location
    USA, IL
    MS-Off Ver
    Excel 2010
    Posts
    121

    Re: formula to show first and last row results based on creteria

    Thank you Ghozi Alkatiri for the assistance but it seems the formula shows the same results instead of the first and last value of the criteria. I uploaded a sample file

  6. #6
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,364

    Re: formula to show first and last row results based on creteria

    These worke fine for me (asper original formulae)

    =INDEX($B$1:$B$18,MIN(IF($A$1:$A$18=E2,ROW($A$1:$A$18))))

    =INDEX($B$1:$B$18,MAX(IF($A$1:$A$18=E2,ROW($A$1:$A$18))))

    BOTH ...confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer.

    THEN copy/Paste in pairs
    Attached Files Attached Files

  7. #7
    Valued Forum Contributor
    Join Date
    10-29-2012
    Location
    Mojokerto,Indonesia
    MS-Off Ver
    Excel 2007
    Posts
    554

    Re: formula to show first and last row results based on creteria

    at F2 try this formula (formula array)
    =INDEX($B$2:$B$18,IF(COUNTIF(E$2:E2,E2)=1,MIN(IF($A$2:$A$18=E2,ROW($A$2:$A$18)-1)),MAX(IF($A$2:$A$18=E2,ROW($A$2:$A$18)-1))))
    copy down

  8. #8
    Forum Contributor
    Join Date
    03-17-2013
    Location
    USA, IL
    MS-Off Ver
    Excel 2010
    Posts
    121

    Re: formula to show first and last row results based on creteria

    Perfect Ghozi Alkatire! Thank you Sir.

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

    Re: formula to show first and last row results based on creteria

    Another way non array entered.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Dave

  10. #10
    Forum Contributor
    Join Date
    03-17-2013
    Location
    USA, IL
    MS-Off Ver
    Excel 2010
    Posts
    121

    Re: formula to show first and last row results based on creteria

    Thank you also FlameRetired.

+ 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] Lookup creteria match formula with results in rows (horizontal)
    By Pi* in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 11-05-2017, 10:17 PM
  2. [SOLVED] cumulative calculation based on different creteria
    By roofi in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 12-04-2015, 04:36 PM
  3. Copy Cells based on Creteria
    By Barieq in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-12-2015, 06:55 AM
  4. [SOLVED] Using VLookup but results show formula instead of results...
    By excel me in forum Excel Formulas & Functions
    Replies: 19
    Last Post: 11-28-2013, 09:40 PM
  5. [SOLVED] Calculate based on cell value but dont show negative results
    By shiftyspina in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-19-2013, 06:15 AM
  6. Lock cells based on creteria
    By rizmomin in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-26-2012, 06:39 PM
  7. Show results based on pull down box
    By DaKohlmeyer in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 07-29-2008, 03:54 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