+ Reply to Thread
Results 1 to 11 of 11

VBA Auto copy rows to multiple sheets by criteria

  1. #1
    Registered User
    Join Date
    01-21-2014
    Location
    Lithuania
    MS-Off Ver
    Excel 2010
    Posts
    5

    VBA Auto copy rows to multiple sheets by criteria

    Hello,
    I'm new to programming with VBA, but i have a serious problem, and I thought You guys could help me.
    Here's the thing - I have MS excel document with 8 sheets in it. The first one is named "Orders", the second one "Direction1", the third, "Direction2", the fourth "Direction3", then "Direction4", "Direction5", "Direction6", "Direction7".
    In the "Orders" sheet C column has numbers based on the direction from 1 to 7. What I would like excel to do, is to find the number in C column (1 to 7) and copy that entire row accordingly to direction.
    For example:
    if number in column C is 6, excel should copy entire row to Direction 6.

    Few things to mention - information in "Orders" sheet is always changing.
    And second thing orders in sheets shouldn't left any empty rows between each other.

    I would be very grateful for Your help, because now I'm doing this copy/paste with my mouse :\

  2. #2
    Valued Forum Contributor
    Join Date
    03-22-2013
    Location
    Australia,NSW, Wirrimbi
    MS-Off Ver
    Excel 2013
    Posts
    1,057

    Re: VBA Auto copy rows to multiple sheets by criteria

    Did you want to copy the entire row to the direction sheet (leaving the row still in the Orders sheet).. or.. move the entire row to the direction sheet (so it no longer exists in the Order sheet)..?

  3. #3
    Registered User
    Join Date
    01-21-2014
    Location
    Lithuania
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: VBA Auto copy rows to multiple sheets by criteria

    I wanted to copy entire row to direction sheet.

  4. #4
    Valued Forum Contributor
    Join Date
    03-22-2013
    Location
    Australia,NSW, Wirrimbi
    MS-Off Ver
    Excel 2013
    Posts
    1,057

    Re: VBA Auto copy rows to multiple sheets by criteria

    Hi..

    This will do it..

    If you have any problems adapting it to your real workbook.. let me know..

    Please Login or Register  to view this content.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    01-21-2014
    Location
    Lithuania
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: VBA Auto copy rows to multiple sheets by criteria

    Thank You very much!!!
    First thing - excel MOVES information to according sheets, I need it to copy the information.
    Second thing, my real work book direction sheets have different names. what should I do to adapt it to my real workbook?
    Attached Files Attached Files

  6. #6
    Valued Forum Contributor
    Join Date
    03-22-2013
    Location
    Australia,NSW, Wirrimbi
    MS-Off Ver
    Excel 2013
    Posts
    1,057

    Re: VBA Auto copy rows to multiple sheets by criteria

    Hi..

    First thing - excel MOVES information to according sheets, I need it to copy the information.
    Initially i made it copy the data.. then remember the range of the data that was copied then cleared it at the end..

    I have changed it so it doesn't clear it now.. but are you sure that's what you want?.. What happens if you run the macro twice.. it will copy the same data to the other sheets.??
    Anyway..
    This should do it..
    Please Login or Register  to view this content.
    Second thing, my real work book direction sheets have different names. what should I do to adapt it to my real workbook?
    Only thing there was to make the autofilter criteria be set by the 'i' variable.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    01-21-2014
    Location
    Lithuania
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: VBA Auto copy rows to multiple sheets by criteria

    Yes, I'm sure i need it to copy. And one last thing - where goes all the orders with direction "1"? They should go to first direction sheet, but in that sheet there are orders with direction "2".

  8. #8
    Valued Forum Contributor
    Join Date
    11-15-2008
    Location
    ph
    MS-Off Ver
    2007/2010/2016
    Posts
    479

    Re: VBA Auto copy rows to multiple sheets by criteria

    Hi -

    Change this line from apo's codes
    from
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.
    event

  9. #9
    Registered User
    Join Date
    01-21-2014
    Location
    Lithuania
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: VBA Auto copy rows to multiple sheets by criteria

    Works like a charm! Thank You! You just made my life much easier.

  10. #10
    Valued Forum Contributor
    Join Date
    03-22-2013
    Location
    Australia,NSW, Wirrimbi
    MS-Off Ver
    Excel 2013
    Posts
    1,057

    Re: VBA Auto copy rows to multiple sheets by criteria

    Good catch event21.. i rushed that one..

  11. #11
    Valued Forum Contributor
    Join Date
    11-15-2008
    Location
    ph
    MS-Off Ver
    2007/2010/2016
    Posts
    479

    Re: VBA Auto copy rows to multiple sheets by criteria

    no problem, apo

    event

+ 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. Copy rows to 2 sheets using criteria
    By moroformat in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-21-2013, 11:49 PM
  2. Macro to copy rows based on column criteria to a new sheets
    By Scott821 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-17-2012, 01:55 AM
  3. Copy Rows From Two Sheets Into Master Based On Criteria
    By longstrider in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-28-2012, 05:17 PM
  4. Copy rows from master sheet to other sheets based on criteria
    By spikeysas in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-07-2011, 04:28 AM
  5. Replies: 1
    Last Post: 07-29-2011, 05:03 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