+ Reply to Thread
Results 1 to 15 of 15

macro required to filter data on several tabs and save to a file, then repeating action

  1. #1
    Registered User
    Join Date
    09-23-2011
    Location
    Norwich, England
    MS-Off Ver
    Excel 2003
    Posts
    34

    macro required to filter data on several tabs and save to a file, then repeating action

    Hi guys,

    I would like to implement a macro on a very large spreadsheet tha tis generated each week.

    What I'd like is to be able to filter Column 1, I woudl also like this to be the same across several tabs. So each tab would display only the data for 'Patch 1' for example.

    Once this is displayed I'd then like to be able to save it as a seperate sheet plus the date. So the save name would be something like Patch 1 April 2012.

    I'd then need to repeate this process with all other 'Patches'.

    Could anyone lend a hand?

    I know my way around java to an extent but vb is like a wild creature to me

    Many thanks in advance.
    Last edited by Stevengreen22; 04-04-2012 at 05:16 AM. Reason: ...

  2. #2
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,602

    Re: Maco help please

    Forum Rules
    Please read and adhere to these simple rules!

    1. Use concise, accurate thread titles. Your post title should describe your problem, not your anticipated solution. Use terms appropriate to a Google search. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will be addressed according to the OP's experience in the forum: If you have less than 10 posts, expect (and respond to) a request to change your thread title. If you have 10 or more posts, expect your post to be locked, so you can start a new thread with an appropriate title.

    To change the title of the thread, click EDIT on the original post, then click the Go Advanced button, then change the title. If two or more hours have passed, the EDIT button will not appear, and you need to ask a moderator to change the title.

  3. #3
    Registered User
    Join Date
    09-23-2011
    Location
    Norwich, England
    MS-Off Ver
    Excel 2003
    Posts
    34

    Re: macro required to filter data on several tabs and save to a file, then repeating actio

    zbor - now that you've taken the time to check the title, do you have a siggestion as to how I might solve the problem?

  4. #4
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,602

    Re: macro required to filter data on several tabs and save to a file, then repeating actio

    I'm not good at macro but not that you corrected title other would be able to participate in the solution.

  5. #5
    Registered User
    Join Date
    09-23-2011
    Location
    Norwich, England
    MS-Off Ver
    Excel 2003
    Posts
    34

    Re: macro required to filter data on several tabs and save to a file, then repeating actio

    No Problem, I have it working but the code is very ugly.

    Its essentially reiterating the code every time instead of being in a loop

    Please Login or Register  to view this content.
    What I'd like if possible is to contain this in a loop. Is it possible to create an array/loop that will cycle through each one? I can't expalin so well but essentaially
    >
    for int i=0; i<number of patches; i++{

    above code

    Save as filename patch+(i);

    }

    Any help would be greatly appreaciated, many thanks.

  6. #6
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: macro required to filter data on several tabs and save to a file, then repeating actio

    After the data is filtered in column 1 in all tabs, do you want that data to be copied to a separate workbook? If you do not do so but just save the workbook with another name, the data that is not filtered will also be there in the workbook.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  7. #7
    Registered User
    Join Date
    09-23-2011
    Location
    Norwich, England
    MS-Off Ver
    Excel 2003
    Posts
    34

    Re: macro required to filter data on several tabs and save to a file, then repeating actio

    Hi Arletter, that's effectively what I've done but the code is 'ugly' what I pasted above is reiterated 13 times and it seemed unnecessary.

    Would be nice if I could contain it all within a loop instead?

  8. #8
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: macro required to filter data on several tabs and save to a file, then repeating actio

    Yes thats doable. Your code above only shows the filtering. There is no copy paste code, so i asked you. Should all the sheets in the file be filtered? Are there any sheets to be excluded?

  9. #9
    Registered User
    Join Date
    09-23-2011
    Location
    Norwich, England
    MS-Off Ver
    Excel 2003
    Posts
    34

    Re: macro required to filter data on several tabs and save to a file, then repeating actio

    Hi,

    Sorry for not answering your earlier question. The code above repeats itself 12 times with just the patch and save name changing. Theres one tab that doesn't get checked which contains graphs etc. All sheets bar this one should be filtered.

    >
    Also, as a side note, I realised my idea was bad pratice as I'm effectively creating 12 5+mb sheets which should be a great deal smaller.
    I'm thinking that because I use the 'main' sheet I don't want to delete any unfiltered/selected cells before saving as I may not be able to undo the action so that leads me to think that I'd need to create a new sheet for every filter (patch 3) and then save These sheets only as a new workbook, then delete sheets and repeat process.

    Is this doable at all?

  10. #10
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: macro required to filter data on several tabs and save to a file, then repeating actio

    Yes its doable. What do you mean by delete sheets & repeat process? Do you mean the next time you want to run the macro, you want the sheets to be deleted and then the filtered data to be input?

  11. #11
    Registered User
    Join Date
    09-23-2011
    Location
    Norwich, England
    MS-Off Ver
    Excel 2003
    Posts
    34

    Re: macro required to filter data on several tabs and save to a file, then repeating actio

    I'm sent a 'comprehensive' sheet as a report each week. I need to keep a copy of it intact.

    I think I made a poor effort at explaining what I'd like.

    I'd like each of the sheets within the workbook to be filtered. Then save only the selected data as a new file.

    I'd then need to repeat this process but with a different filter name.

    If I can do this without compromising the integrity of the original, I'd be happy And within a loop of course Many thanks again!

  12. #12
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: macro required to filter data on several tabs and save to a file, then repeating actio

    Ok got it now. So one of your filters is Patch 3. What about the others? Are they also Patch + #? Just asking so that the filters can be looped as well.

  13. #13
    Registered User
    Join Date
    09-23-2011
    Location
    Norwich, England
    MS-Off Ver
    Excel 2003
    Posts
    34

    Re: macro required to filter data on several tabs and save to a file, then repeating actio

    Yes, they're all patch and then a number, patch 1, patch 2,...,patch 12.

  14. #14
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: macro required to filter data on several tabs and save to a file, then repeating actio

    It will be good if you provide a sample workbook, it will be faster to provide you a solution.

  15. #15
    Registered User
    Join Date
    09-23-2011
    Location
    Norwich, England
    MS-Off Ver
    Excel 2003
    Posts
    34

    Re: macro required to filter data on several tabs and save to a file, then repeating actio

    Hi,

    I'm afraid I can't provide sample data due to it's nature.

    I've attached a very basic workbook that comprises some of the same features.

    testSheet.xls

    I've had a play with some for each statements but can't seem to get it working. I keep tinking of how I'd do it in java and it's no good at all. VBA is a mystery. As always, any help is greatly appreciated.

+ 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