+ Reply to Thread
Results 1 to 8 of 8

Conditionally copy data from one sheet to another

  1. #1
    Registered User
    Join Date
    03-30-2013
    Location
    Brazil
    MS-Off Ver
    Excel 2007
    Posts
    8

    Conditionally copy data from one sheet to another

    Hello again guys,
    So, I'm trying to build a code that can do the following:
    I have a large datasheet, several columns and about 3,5k lines, and one of these columns has a number. If this number is above 2 (200%), I want to copy some of the data on the other columns to a previously made worksheet.
    Being more specific: the numbers are at colum V. If it's > 200%, I'd like to copy the data (string data) from columns B, C, E, F and V itself to this new sheet. I believe a button would be the best way to update (evertime you click it, it copies the ones above 2).
    It looks actually rather easy, as I can think of the code. But i don't know the language very well...

    Anyway you guys can help me, in any form? I'd greatly appreciate.
    Thanks in advance,

    Cheers!

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,053

    Re: Conditionally copy data from one sheet to another

    Im sure that some-one will give you the code for this, but I would use formulas.

    On the sheet with the data, in a helper column (W if thats the 1st empty column), use something likethis, copied down...
    =if(V2>2,max($W$1:W1)+1,max($W$1:W1))
    Then on sheet1, using index/match to extract the data...
    =index(B1:B200,match(row(A1),$W$1:$W$200,0),1)
    copy across for teh other columns
    (I did this blind - no sample data - so I may have some ranges/syntax a bit off lol)
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Registered User
    Join Date
    03-30-2013
    Location
    Brazil
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Conditionally copy data from one sheet to another

    Hi there, thanks for the reply!
    So, I didnt manage to use that actually... on column W all I got we're errors for dividing by 0 (it said cause of circular reference).
    What is the IF formula supose to do? Didn't quite understand it...

    Thank you very much for your time.
    Cheers!

  4. #4
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,053

    Re: Conditionally copy data from one sheet to another

    This goes in W2, and what it does is creates a sequence of numbers for rows that match a condition. Sot the 1st match generates a 1, each row from then on down stays 1, until the next match is found, and it becomes 2 etc
    =if(V2>2,max($W$1:W1)+1,max($W$1:W1))

    Then the next formula extracts values based in teh 1st instance of 1, then the 1st instance of 2 etc
    =index(B1:B200,match(row(A1),$W$1:$W$200,0),1)

    If you have a sample workbook, I can show you how it works

  5. #5
    Registered User
    Join Date
    03-30-2013
    Location
    Brazil
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Conditionally copy data from one sheet to another

    Thanks! It did work now.
    My only concern is that, as the datasheet changes I'll have to keep inputing the formula and dragging it down. But it works wonders.
    Thank you very much, I thought it would be somewhat more complicated... I'll start using those formulas from now on.

    Cheers!

  6. #6
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,053

    Re: Conditionally copy data from one sheet to another

    you could modify both of those to only "fire" if there is data in that row. That way you can copy it down some way paste where your current data end...
    =if(V2="","",if(V2>2,max($W$1:W1)+1,max($W$1:W1)))
    =iferror(index(B1:B200,match(row(A1),$W$1:$W$200,0),1),"")

    Thanks for the feedback

  7. #7
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,053

    Re: Conditionally copy data from one sheet to another

    self-deleted duplicate post

  8. #8
    Registered User
    Join Date
    03-30-2013
    Location
    Brazil
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Conditionally copy data from one sheet to another

    Thanks again! Awesome work.

+ 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