+ Reply to Thread
Results 1 to 10 of 10

Macro to filter and copy visible data to a New Work Book

  1. #1
    Forum Contributor
    Join Date
    01-03-2012
    Location
    Sydney
    MS-Off Ver
    Excel 2016,Excel 2013
    Posts
    186

    Macro to filter and copy visible data to a New Work Book

    Hi guys,

    I have got a file with 10 different Sheets with massive data . I want to create a light version of the file with the help of a Macro.
    The Macro needs to do the following tasks,

    1) Select Specific Sheet and unprotect the sheet.
    2) Apply filter ,(I'm using Icons to filter the data) on Column D
    3) Copy this filtered data (Only Visible Cells) into a new book Called "Light Version".

    The above process repeats until 5 sheets are copied over into one file called "Light Version" and breaks the link file
    to the source file. (Please note since there would be some defined names from the source file, the macro should delete all the
    Names from the Name manager in the "Light Version file", before it can enable to break the link.

    Any help is appreciated.

    Thanks

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,483

    Re: Macro to filter and copy visible data to a New Work Book

    Post a Simple Sample WORKBOOK.
    To attach a file, push the button with the paperclip (or scroll down to the Manage Attachments button), browse to the required file, and then push the Upload button.

  3. #3
    Forum Contributor
    Join Date
    01-03-2012
    Location
    Sydney
    MS-Off Ver
    Excel 2016,Excel 2013
    Posts
    186

    Re: Macro to filter and copy visible data to a New Work Book

    Hi Dave

    Attached please find a sample file. In the original file, there are various sheets but included in them will have 5 similar sheets as of my sample file.
    I need a macro to select these 5 sheets where filter needs to be applied in column D (By Selecting Filter Icon(Green Tick)in each of these sheets and then copy over to a new file with visible data only.
    Hope its clear!
    Cheers
    Attached Files Attached Files

  4. #4
    Forum Contributor
    Join Date
    01-03-2012
    Location
    Sydney
    MS-Off Ver
    Excel 2016,Excel 2013
    Posts
    186

    Re: Macro to filter and copy visible data to a New Work Book

    Hi Dave,

    Did you get a chance to look at my thread. I have attached the sample file as requested.

    Thanks

  5. #5
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,483

    Re: Macro to filter and copy visible data to a New Work Book

    Haven't been able to get on the site for a couple of days some kind of issue that only happens with this website.
    I haven't looked at it yet

  6. #6
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,483

    Re: Macro to filter and copy visible data to a New Work Book

    It took a while to realize that the copied filtered data into the new workbook was actually correct. The ckecks and X's change in the new workbook but the count and sum equal in both the filtered range and the new workbook.
    I am not familiar yet with how the checks and X's are used as I have never had to use them.

    Anyway, here is the code that will filter your checks and copy and paste the filtered data into the new workbook.
    Only the filtered data will be copied(starting at the 5th row), you have too many merged cells above row 5 that causes problems when being copied.
    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    01-03-2012
    Location
    Sydney
    MS-Off Ver
    Excel 2016,Excel 2013
    Posts
    186

    Re: Macro to filter and copy visible data to a New Work Book

    Hi Dave,

    I somehow was able to formulate the macro to work as what I wanted . The macro creates the file and copies the filtered data .
    However I realised that the macro does not work today basically I learnt that I want the macro to create in xlsx version while the group settings
    in the company have defaulted to create an xls version. The macro works when I go and change the excel options however these settings cannot be saved.
    Once I close and reopen excel, the default settings gets activate and my macro debugs.
    Below is the code and I have highlighted where it bugs, Appreciate if you can help me here.

    Please Login or Register  to view this content.
    Last edited by davesexcel; 03-15-2012 at 12:39 AM. Reason: No Code tags??

  8. #8
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,483

    Re: Macro to filter and copy visible data to a New Work Book

    I am not sure what is happening, the code works fine with the example you provided.
    The conditional formatting used for the example you provided will not work for pre xl'07.
    Moving an xl'07 worksheet to an xl'03 will not work because xl'07 has 1 million rows and xl'03 only has 63K rows.

  9. #9
    Forum Contributor
    Join Date
    01-03-2012
    Location
    Sydney
    MS-Off Ver
    Excel 2016,Excel 2013
    Posts
    186

    Re: Macro to filter and copy visible data to a New Work Book

    Hi Dave ,

    The macro works only when I customise the excel save options to xlsx version . However I cannot save
    this settings as it requires company's groups settings access.
    Alternatively, I was able to customise these settings by copying over a dummy xlsx file within XLSTART folder in my user profile. Now whenever excel opens, it saves in 2007 excel version.

    Despite the above changes, the macro is not able to call the "Light Version.xlsx" file which it creates at
    the beginning of the macro.

    Can you redirect this issue to someone who may help?

    Thanks

  10. #10
    Forum Contributor
    Join Date
    01-03-2012
    Location
    Sydney
    MS-Off Ver
    Excel 2016,Excel 2013
    Posts
    186

    Re: Macro to filter and copy visible data to a New Work Book

    Thanks Rory

    I tried your code but it does not help. I have figured out what the problem is , which I have posted in my previous reply in the thread.
    The VBA code works perfectly when I change the excel Save Options to 2007 version from its default setting as 2003. However I cannot save these settings in my user profile, as it needs group settings which only the IT Dept in our company can do it and as some people in the organisation have only 2003 version, these settings cannot be changed anytime soon. I'm curious is there something else which can I can tweak the code which stills allows me to create the excel file in 2007 and save the file.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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