+ Reply to Thread
Results 1 to 3 of 3

Only return cells with a value

  1. #1
    Forum Contributor
    Join Date
    02-14-2011
    Location
    West Valley City, Utah
    MS-Off Ver
    Excel 2010
    Posts
    108

    Only return cells with a value

    Good afternoon all,

    I'm trying to put together a formula that will look through a column for values greater than 0 and return another cell's value for those cells that do have a value greater than 0. For example, if I5 has a value of 6, I6 has a value of 0, and I7 has a value of 2, I'm hoping for a formula that can be put in A1 and A2 that will return the value in D5 (which is linked to the value in I5 being greater than 0), and the value in D7 (which is linked to I7).


    Thanks in advance

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Only return cells with a value

    Assuming the range of rows to watch is I5:I100, put this array formula into A1:

    =INDEX($D$5:$D$100, SMALL(IF($I$5:$I$100>0, ROW($I$5:$I$100)-4, ""), ROW($A1)))

    ...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. Press F2 on that cell and try again.

    Now copy A1 down as far as you want for as many answers as you want to retrieve.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

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

    Re: Only return cells with a value

    Here's another one if you're using Excel 2010 or later.

    Entered in A1:

    =IFERROR(INDEX(D:D,AGGREGATE(15,6,1/(I$5:I$10>0)*ROW(I$5:I$10),ROWS(A$1:A1))),"")

    Copy down until you get blanks.

    Adjust the range I5:I10 to suit.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

+ 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. Replies: 8
    Last Post: 05-16-2013, 05:28 PM
  2. Replies: 2
    Last Post: 11-12-2012, 06:26 AM
  3. print only formulated cells that return numbers rather than cells that return blank
    By jaganath in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-24-2010, 03:46 PM
  4. Replies: 3
    Last Post: 11-22-2007, 07:53 AM
  5. Replies: 0
    Last Post: 09-05-2005, 10:05 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