+ Reply to Thread
Results 1 to 8 of 8

Copy Rows to another Worksheet Based on a Condition

  1. #1
    Registered User
    Join Date
    02-02-2004
    Location
    Michigan USA
    MS-Off Ver
    2010
    Posts
    21

    Copy Rows to another Worksheet Based on a Condition

    I have created a worksheet which contains seven columns of data and many rows. I need to copy entire rows into nine separate worksheets depending on the data in column G.

    I know nothing about VBA but have read enough to realize this is the way to go with this. Would someone point me in the right direction on how to set this up?

    I've attached the file so you can better see what I'm talking about.

    Thanks. Pat
    Attached Files Attached Files
    Last edited by patxlb; 09-18-2009 at 11:50 AM.

  2. #2
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Copy Rows to another Worksheet Based on a Condition

    Try this:

    Please Login or Register  to view this content.
    Is your code running too slowly?
    Does your workbook or database have a bunch of duplicate pieces of data?
    Have a look at this article to learn the best ways to set up your projects.
    It will save both time and effort in the long run!


    Dave

  3. #3
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,607

    Re: Copy Rows to another Worksheet Based on a Condition

    Try this:
    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    02-02-2004
    Location
    Michigan USA
    MS-Off Ver
    2010
    Posts
    21

    Re: Copy Rows to another Worksheet Based on a Condition

    Thank you both so much. This works perfectly.

  5. #5
    Registered User
    Join Date
    02-03-2010
    Location
    Texas
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Copy Rows to another Worksheet Based on a Condition

    First off, thank you for what you do! I am self-taught (arguably by a pretty shoddy teacher), and am determined to figure *some* of this stuff out. I've come to this forum many many times to work through issues.

    I have modified the code by DaveGuggs above to fit my workbook. It works great and is WAY simpler than the code I had clunked out. I need to make one small change- in the row where it copies and pastes the data to the new sheet, I would like to only copy the data in column A through E, not the entire row.

    I tried a bunch of things, for example, in this row

    Sheets("Data").Rows(i).Copy Destination:=Sheets(Sheets("Data").Cells(i, "G").Value).Cells(lngDestRow, 1)

    I put in

    Cells(I & "A", I & "E")

    in place of

    Rows(i)

    But it returned an error 13, type mismatch. What do I need to put in to only copy columns A through E of row I?

    Thank you much!
    Al

  6. #6
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Copy Rows to another Worksheet Based on a Condition

    You need to start a new thread for this request. Post the code you are using and how it is not working for you.

  7. #7
    Registered User
    Join Date
    03-25-2013
    Location
    Portugal
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Copy Rows to another Worksheet Based on a Condition

    Did you manage to copy only the data in column A through E in the macro?
    I need the same code!
    If yes, please send it to me (or post here).

    Thank you

  8. #8
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Excel 2016
    Posts
    10,052

    Re: Copy Rows to another Worksheet Based on a Condition

    Hello cambralenta & Welcome to the Forum,

    Unfortunately your post does not comply with Rule 2 of our Forum RULES. Do not post a question in the thread of another member -- start your own thread.

    If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread.

    Old threads are often only monitored by the original participants. New threads not only open you up to all possible participants again, they typically get faster response, too.
    HTH
    Regards, Jeff

+ 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