+ Reply to Thread
Results 1 to 6 of 6

Formula: copy rows in a range, based on non-blank values in one of the columns

Hybrid View

  1. #1
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,274

    Formula: copy rows in a range, based on non-blank values in one of the columns

    It never fails to amaze me what Excel can do - however, I'm still a novice!

    There are lots of similar threads on the www, but I haven't been able to find exactly what I need.

    I have a large data table (20+columns, 500+ rows) of data.

    In one column (column C in the attached example), there may be some blank cells.

    I want to use a formula (trying to avoid VBA - a dark art...) to copy onto another sheet, only those rows where there is a value (always a number) in column C.

    As usual, this is part of a larger project. I've got all the fancy data analysis at the end of the process all sorted out, but I'm struggling to get the valid dataset arranged. Can you help??
    Attached Files Attached Files
    Last edited by Glenn Kennedy; 08-16-2013 at 04:57 AM.

  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: Formula: copy rows in a range, based on non-blank values in one of the columns

    1) Move the "Before" list up so that it starts in A1.
    2) On Sheet2, put in these formulas:
    A1: =IF(ISNUMBER(Sheet1!A1), Sheet1!A1, "")
    B1: =IF(ISTEXT(Sheet1!A1), "", LOOKUP(2, 1/(ISTEXT(Sheet1!$A$1:$A1)), Sheet1!$A$1:$A1))

    3) Copy A1:B1 down.



    Notice one of your dates is broken.
    _________________
    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 Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,274

    Re: Formula: copy rows in a range, based on non-blank values in one of the columns

    Jerry,

    Arrgghhh. Where do I begin? In my rush out htis morning, I attached the wrong file!! I have replaced it with the correct one.
    I wondered what you meant by the wrong dates...

    100,000 apologies...

  4. #4
    Valued Forum Contributor
    Join Date
    09-15-2011
    Location
    Chennai, India
    MS-Off Ver
    Excel 2010
    Posts
    436

    Re: Formula: copy rows in a range, based on non-blank values in one of the columns

    Try this file
    Attached Files Attached Files
    Please click 'Add reputation', if my answer helped you.

  5. #5
    Valued Forum Contributor wenqq3's Avatar
    Join Date
    04-01-2013
    Location
    Malaysia
    MS-Off Ver
    Excel 2003
    Posts
    868

    Re: Formula: copy rows in a range, based on non-blank values in one of the columns

    L2
    =IFERROR(INDEX($A$1:$E$11,SMALL(IF(ISNUMBER($D$2:$D$11),ROW($A$2:$A$11),""),ROW($A1)),1),"")
    M2
    =IFERROR(INDEX($A$1:$E$11,SMALL(IF(ISNUMBER($D$2:$D$11),ROW($A$2:$A$11),""),ROW($A1)),2),"")
    N2
    =IFERROR(INDEX($A$1:$E$11,SMALL(IF(ISNUMBER($D$2:$D$11),ROW($A$2:$A$11),""),ROW($A1)),3),"")
    O2
    =IFERROR(INDEX($A$1:$E$11,SMALL(IF(ISNUMBER($D$2:$D$11),ROW($A$2:$A$11),""),ROW($A1)),4),"")
    P2
    =IFERROR(INDEX($A$1:$E$11,SMALL(IF(ISNUMBER($D$2:$D$11),ROW($A$2:$A$11),""),ROW($A1)),5),"")
    Every time you copy and paste above code, dont just enter, CTRL + SHIFT + ENTER

    After that, drag down.
    -If the problem is solved, please mark your thread as Solved: Click Thread Tools above your first post, select "Mark your thread as Solved".

    -Always upload a workbook before start your question
    To attach a file, push the button with the paperclip (or scroll down to the Manage Attachments button), browse to the required file, and then push the Upload button.

    +++ If my answer(s) helped you, please add me reputation by click on * +++

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

    Re: Formula: copy rows in a range, based on non-blank values in one of the columns

    Non array solution:

    G1: "key"
    G2: =IF(ISNUMBER(D2), N(G1)+1, N(G1))

    Copy G2 down the data set.

    L2: =IF(ROW(A1)>MAX($G:$G), "", INDEX(A:A, MATCH(ROW(A1),$G:$G, 0)))

    Copy L2 down and across the table.

+ 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. Compare two sheets,copy and paste unique rows based on values in 2 columns
    By ooggiemobile in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-02-2013, 03:58 AM
  2. [SOLVED] Copy data from a range of cells into a blank range based on common cell
    By vanmeterkj in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-03-2012, 10:18 AM
  3. copy rows based on values of 2 columns (2 conditions)
    By kingpeejay in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-02-2009, 04:53 PM
  4. insert blank rows based on columns a values numerically
    By elkhole in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 05-18-2009, 04:57 AM
  5. [SOLVED] Macro simplifying - copy rows to worksheets based on values in 2 different columns
    By markx in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-27-2006, 11:40 AM

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