+ Reply to Thread
Results 1 to 7 of 7

Extract all data to new workbook then filter and extract to new worksheets

  1. #1
    Registered User
    Join Date
    11-14-2013
    Location
    Perth, Western Australia
    MS-Off Ver
    Excel 2016
    Posts
    49

    Extract all data to new workbook then filter and extract to new worksheets

    Hi,

    I've been playing with this for a bit and had a search around and haven't been able to find the answer to my issue. I have a spreadsheet that contains geological drilling results for different ore bodies. All results go into the one spreadsheet and I'm after a macro that will filter based on each ore body and export the entire rows from each ore body separately to new workbooks. I've had this work, BUT once the new workbooks have been created I would then like to filter based on a certain column and then copy the results into new sheets based on a value ranges of the filtered cell and then rename these sheets to reflect the value range of that sheet (i.e. I want to filter based on a "GMM" value between ranges "<25", "25-50", "50-75", "75-100", "100-200", "200-300", ">300" and have those ranges be the sheet name at the end). I've got a macro, but it fails once the data gets to the new workbook.

    Please Login or Register  to view this content.

  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: Extract all data to new workbook then filter and extract to new worksheets

    I would continue to use the AutoFilter to accomplish all this enmasse, see if you can use or adapt this approach:

    Please Login or Register  to view this content.
    _________________
    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
    Registered User
    Join Date
    11-14-2013
    Location
    Perth, Western Australia
    MS-Off Ver
    Excel 2016
    Posts
    49

    Re: Extract all data to new workbook then filter and extract to new worksheets

    Thanks for your reply JBeaucaire. That's a much more simplistic approach, however there seems to be something it doesn't like. When I run the macro with your code it fails on the line:

    Please Login or Register  to view this content.

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

    Re: Extract all data to new workbook then filter and extract to new worksheets

    When you debug, look at your sheet at that moment and see if there are any rows visible? If not, and if that is something that will frequently occur, then you'll need to test/count visible rows before trying to copy.

    Please Login or Register  to view this content.
    Lather, rinse, repeat.

  5. #5
    Registered User
    Join Date
    11-14-2013
    Location
    Perth, Western Australia
    MS-Off Ver
    Excel 2016
    Posts
    49

    Re: Extract all data to new workbook then filter and extract to new worksheets

    When I debug there are rows visible, not just the headers. It gets to the point where it's filtered for the first ore body and then exports this to a new workbook but in the new workbook it has copied ALL the rows from the original workbook, not just the ones that were filtered. So it has hidden rows that will have values that I don't want in that particular new workbook, as the other rows associated with different ore bodies should get copied out to their own workbook...if I'm making sense?

  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: Extract all data to new workbook then filter and extract to new worksheets

    Maybe this:
    Please Login or Register  to view this content.
    Should be this:
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    11-14-2013
    Location
    Perth, Western Australia
    MS-Off Ver
    Excel 2016
    Posts
    49

    Re: Extract all data to new workbook then filter and extract to new worksheets

    As mentioned above, I was having trouble with this line of code failing:

    Please Login or Register  to view this content.
    I did a bit of testing and playing and recorded some macros doing what I wanted it to do, to see what would work and what wouldn't. So I've now got a macro that works, as per below. BUT it takes literally 10minutes to run given it's doing a whole bunch of physical copying, pasting etc. I'm just wondering if anyone would please be able to take a look at my code and see if they could streamline it so that it runs a lot quicker but still gives me the same result?

    Please Login or Register  to view this content.
    Many thanks

+ 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] Extract selective data from multiple worksheets into a new workbook
    By bukit13 in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 12-03-2013, 03:58 AM
  2. Extract Data from multiple worksheets within a workbook
    By gymnst920 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-27-2013, 09:37 AM
  3. Macro to Filter & Extract Data to a New Workbook
    By foxluc in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-05-2011, 10:53 AM
  4. Replies: 3
    Last Post: 11-03-2011, 02:30 PM
  5. [SOLVED] merge/extract data from identical worksheets in a workbook
    By Michelle K in forum Excel General
    Replies: 5
    Last Post: 06-21-2005, 01:05 PM

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