+ Reply to Thread
Results 1 to 4 of 4

Copy rows based on criteria to multiple dynamically named worksheets

  1. #1
    Registered User
    Join Date
    01-28-2015
    Location
    Peoria, Illinois
    MS-Off Ver
    2013
    Posts
    23

    Copy rows based on criteria to multiple dynamically named worksheets

    I've made a lot of progress in my code, however, I have come to a impasse. Any help is appreciated with my issues.

    Here's what my current code does:
    1) On "Sheet1" the code removes all columns deemed unnecessary
    next it
    2) creates "Sheet2" and copies all cells from "Sheet1" column C2 (Items) down and removes any duplicate values
    then the
    3) Code looks at the values in "A:A" on "Sheet2" and creates additional worksheets based upon the populated cells, and populates each new worksheet row 1 with headers
    Finally, the code will delete "Sheet2" (i'd rather be able to hold the values in an array, however, I am still a beginner)

    and that is where I am at for the moment...

    I can use some assistance for the next steps:

    4) Now that the new "worksheets" are created, I want the code to go back to "Sheet1"
    and copy each row that matches column C (ITEM) into it's respectively named "Worksheet" starting at A2, and once all rows have been copied to each new worksheet, the code is complete.

    I have attached the Workbook with working code and data.
    On "Sheet1" I have a button for you to click to run the macro (for ease of use) the code is within the workbook module "CodeNeedle"
    The two Worksheets populated are Master and Sheet1 - my code does everything else. The Master sheet contains the original data, for when I need to copy the values back to "Sheet1." I have a button for this as well.

    STUFF to REMEMBER:
    The "Sheet1" column C (i mean column C (item), after the macro has been ran) values can change from each use, so the number of worksheets created each time will change

    Thanks for your help!!


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

  2. #2
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: Copy rows based on criteria to multiple dynamically named worksheets

    I think you could just add a snippet into your existing loop.

    Please Login or Register  to view this content.
    Any code provided by me should be tested on a copy or a mock up of your original data before applying it to the original. Some events in VBA cannot be reversed with the undo facility in Excel. If your original post is satisfied, please mark the thread as "Solved". To upload a file, see the banner at top of this page.
    Just when I think I am smart, I learn something new!

  3. #3
    Registered User
    Join Date
    01-28-2015
    Location
    Peoria, Illinois
    MS-Off Ver
    2013
    Posts
    23

    Re: Copy rows based on criteria to multiple dynamically named worksheets

    Thanks for the reply!
    I get an error when running the macro that says object doesn't support this operation or method and the following line highlights in yellow when I debug:

    s1.UsedRange.Offset(1).SpecialCells(xlCellTypeVisible).Copy .Cells(Rows.Count, 1).End(xlUp)(2)

  4. #4
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: Copy rows based on criteria to multiple dynamically named worksheets

    Change that line to this
    Please Login or Register  to view this content.
    Although in testing, I did not get an error with the original code. I am assuming that s1 is the main database according to the code that was posted. That variable should still be valid from what I can interpret from the code. If you are testing the loop without the first part of the code, it would throw an error, but it should then throw it on the previous line as well. Also, make sure the autofilter executed if you still get the error.

+ 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. [SOLVED] Copy rows from multiple worksheets with multiple criteria - greater than dynamic values
    By stackout in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-03-2015, 04:36 PM
  2. [SOLVED] Copy rows from multipe worksheets based on one criteria
    By paulbarratt in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-17-2014, 02:55 PM
  3. [SOLVED] Copy rows from multiple worksheets based on criteria in column
    By Slavica in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-10-2014, 08:45 AM
  4. Macro to copy rows from multiple worksheets based on criteria in range
    By guidovdn in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 11-14-2013, 01:21 PM
  5. copy rows from multiple worksheets to a new condition based on criteria
    By TheVoodoo in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 11-20-2012, 02:37 PM
  6. [SOLVED] Copy data across multiple worksheets (based on three criteria)
    By yunesm in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-17-2012, 12:53 AM
  7. [SOLVED] Copy and paste cells dynamically to a range in a series of named Worksheets.
    By skyping in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 04-27-2012, 04:22 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