+ Reply to Thread
Results 1 to 5 of 5

writing a formula to return non-empty cells

  1. #1
    Registered User
    Join Date
    02-08-2007
    Posts
    11

    writing a formula to return non-empty cells

    Hello,

    I am interested in writing a formula that will output the data from all non empty cells in a large arrays of cells. Is this possible?

    e.g. Cells A20, A21, and A22 contain data. All other cells in column A are empty. I would like to write a formula that can look through A2:A360 and return any data it finds in these cells.

    Thank you,

    Paul

  2. #2
    Forum Contributor
    Join Date
    10-14-2004
    Location
    San Diego, CA
    Posts
    213
    Hello pmetzak:

    Is this what your looking for.

    Matt
    Attached Files Attached Files

  3. #3
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885
    I can't see you doing it with one formula, but I do have two options for you:

    Option 1: Since your data is in A2:A360, in B2 put this formula: =IF(A2="","",A2) . Then in B3 put this formula and fill down to B360: =IF(AND(B2="",A3=""),"",IF(B2="",A3,IF(AND(B2<>"",A3=""),B2,B2&","&A3)))

    Cell B360 will have all non-blank values concatenated, and separated by a comma. Adjust the formula if you don't need a comma to separate entries.

    Option 2 is using a macro:
    Please Login or Register  to view this content.
    This will also join all of your data and separate it with commas, and then put it into cell C1.

  4. #4
    Banned User!
    Join Date
    10-14-2006
    Posts
    1,211
    Quote Originally Posted by pmetzak
    Hello,

    I am interested in writing a formula that will output the data from all non empty cells in a large arrays of cells. Is this possible?

    e.g. Cells A20, A21, and A22 contain data. All other cells in column A are empty. I would like to write a formula that can look through A2:A360 and return any data it finds in these cells.

    Thank you,

    Paul
    rng is a define name range from A2:A360

    =IF(ISERR(SMALL(IF(rng<>"",ROW(INDIRECT("1:"&ROWS(rng)))),ROWS($1:1))),"",INDEX(rng,SMALL(IF(rng<>"",ROW(INDIRECT("1:"&ROWS(rng)))),ROWS($1:1))))

    ctrl+shift+enter, not just enter
    copy down

  5. #5
    Registered User
    Join Date
    02-08-2007
    Posts
    11

    Thanks!

    Hi,

    I just wanted to thank the three of you for posting solutions to my data dilemma. It is greatly appreciated!


    -Paul


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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