+ Reply to Thread
Results 1 to 17 of 17

VBA to auto filter to separate worksheets?

  1. #1
    Forum Contributor
    Join Date
    01-09-2016
    Location
    USA,USA
    MS-Off Ver
    2016
    Posts
    1,192

    VBA to auto filter to separate worksheets?

    I have data that I need to separate out into five different sheets.

    Attached is the workbook.

    Source Sheet is blank, that is where we will copy/paste the raw data too.
    From there we will filter out everything but the cells that begin in "FA"
    All the "FA" cells are then copied to the PAY FILE, starting at A2
    All that is then filtered already on the FILTER worksheet. (currently the formulas in FILTER stops at 200, but that was due to size constraints, original file has it down to A75000)
    Then we filter those and move all the "RH" "VO" "WG" "NSG" "CN"

    For example, I have one row already copied over, you see in Column F, Reason, it has a WG, and there is a corresponding worksheet at the bottom. That would copy from the FILTER page to the WG page.

    Then I have on the Grand Total an autosum formula already in place that pulls the AMT from each worksheet.

    Hopefully that was a decent explanation, but our resident programmer up and quit on us after I spent 8 hours with her yesterday trying to create outlines of how she runs her reports because she had given notice and was helping us be able to transition. So we are in a rock and a hard place.

    She did this manually every month, but I think with the freaking amazing help with macro's i have already received, that maybe I can get that again.
    Attached Files Attached Files
    Last edited by taylorsm; 08-24-2016 at 04:52 PM.

  2. #2
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    4,056

    Re: VBA to auto filter to separate worksheets?

    Let me make sure I understand what you want:
    In "Source", filter for "FA*". Copy results to "Pay File". Easy to do via VBA.
    In "Filter", formulas pull in the separated values from "Pay File". No VBA needed.
    In "Filter", "WG" exists in the "Reason" category. I THINK what you want is that WG line to copy to the WG worksheet (and, I assume, the CN value to copy to the CN worksheet?). If so, this can be done via VBA OR with formulas, your call.
    "Grand Total" worksheet pulls totals from RH:CN worksheets via formulas, no VBA needed.

    Do I understand what you're wanting?

  3. #3
    Forum Contributor
    Join Date
    01-09-2016
    Location
    USA,USA
    MS-Off Ver
    2016
    Posts
    1,192

    Re: VBA to auto filter to separate worksheets?

    I think you have it!

    The Source data is from another file, it changes names so I can't automate that. Put its easy enough to copy to this workbook.
    copy the FA* (like the letters huh? like who doesn't catch that and says, hey wait a minute! lol) to the Payfile
    Then within the Payfile, everything is already filtered around to individual columns.
    Then I need those split between the matching worksheets.

    I think you are 100% right.

    Question though, can we cut out the middle man altogether? Do we need the Filter sheet? Couldn't the "VO" "WG" tabs already look to the source file and if the row starts with FA, and has VO, copy over? But maybe stick to original for now, and improve after I get this out.

  4. #4
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    4,056

    Re: VBA to auto filter to separate worksheets?

    I have to leave for the day, but will get back to this in the morning. But yes, I think we can cut out the middleman.

  5. #5
    Forum Contributor
    Join Date
    01-09-2016
    Location
    USA,USA
    MS-Off Ver
    2016
    Posts
    1,192

    Re: VBA to auto filter to separate worksheets?

    Oh, and a formula would be great.

    I can usually get through a formula and adjust/fix if necessary, or fill to however many rows I need. VBA/Macro I am worse at lol, but can i fumble through it, but I am the only one here at my job (now) that has any experience with them and that is really saying something. So formula might translate into someone else being about to adjust if necessary versus always coming to me.

  6. #6
    Forum Contributor
    Join Date
    01-09-2016
    Location
    USA,USA
    MS-Off Ver
    2016
    Posts
    1,192

    Re: VBA to auto filter to separate worksheets?

    Dude that would be great! Would this be by formula?

    And we'll just make the "source" location the Pay File then instead of having an extra worksheet that I added.

  7. #7
    Registered User
    Join Date
    12-14-2012
    Location
    Czech Republic
    MS-Off Ver
    Excel 2010
    Posts
    92

    Re: VBA to auto filter to separate worksheets?

    Hello,

    This one follows your tab sheets and your description in the first post.I think there are couple of misspells for example: you talk about "NSG" filter tab but there is none in the file (could be "NSF" tab?), some values in Reason column in Filter sheet are not included in the sheets name...

    Well, you can test this if it works for your data. But have to agree with jomili that formulas might be better approach...
    Attached Files Attached Files

  8. #8
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    4,056

    Re: VBA to auto filter to separate worksheets?

    Is your need to get to the Grand Total sheet, or do you need all the other sheets? If Grand Total is all you need, no VBA is required. In Source, put your formulas adjacent to the source data, then on A filter for "FA*". Copy the visible cells from B:K, paste as values on "Filter". Formulas in Filter construct the grand total values.

    You could do it on one sheet if you wanted, Grand Total formulas at the top.
    Attached Files Attached Files

  9. #9
    Forum Contributor
    Join Date
    01-09-2016
    Location
    USA,USA
    MS-Off Ver
    2016
    Posts
    1,192

    Re: VBA to auto filter to separate worksheets?

    Hey syss, yes I apologize about my misspellings, I submitted while still at work and dealing with the fallout lol. Yes NSF. And yes, some of the values in the reason are for whatever reason not important for our purposes.

    And I think I agree and posted it above too that formulas would probably be the better way. I can manage formulas ok, but VBA or anything else is really beyond me and I don't want to have to be the point of contact for this thing forever. I'm just doing this now because we are between a rock and hard place and I want to make sure the task gets done correctly.

    edit**

    Hey Syss, I just ran yours on a file that was sent out yesterday and it didn't copy the files over to the right reasons. It did copy from the source file to the pay file the same number of rows. So that was perfect, but it didn't everything over.

    I attached a sheet that has six examples. Three "RH" and three "VO", so maybe you can see if something is wrong.
    Attached Files Attached Files
    Last edited by taylorsm; 08-25-2016 at 09:09 AM.

  10. #10
    Forum Contributor
    Join Date
    01-09-2016
    Location
    USA,USA
    MS-Off Ver
    2016
    Posts
    1,192

    Re: VBA to auto filter to separate worksheets?

    Hey Jomili, I don't guess I follow your workbook. As far as your question, honestly, I don't know. What you see is what I was given, and the whole workbook is emailed out to everyone, so I would imagine that the extra sheets are used since they give IDs and dates for references and should remain in the book. thanks!

  11. #11
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    4,056

    Re: VBA to auto filter to separate worksheets?

    Sorry, I attached the wrong workbook. See attached.
    Attached Files Attached Files

  12. #12
    Registered User
    Join Date
    12-14-2012
    Location
    Czech Republic
    MS-Off Ver
    Excel 2010
    Posts
    92

    Re: VBA to auto filter to separate worksheets?

    Quote Originally Posted by taylorsm View Post
    Hey Syss, I just ran yours on a file that was sent out yesterday and it didn't copy the files over to the right reasons. It did copy from the source file to the pay file the same number of rows. So that was perfect, but it didn't everything over.

    I attached a sheet that has six examples. Three "RH" and three "VO", so maybe you can see if something is wrong.

    Hi again,

    I put your six rows to the original file, fix something, tested and seemed to work. Please, try this new version attached and let me know.

    regards,
    sysss
    Attached Files Attached Files

  13. #13
    Forum Contributor
    Join Date
    01-09-2016
    Location
    USA,USA
    MS-Off Ver
    2016
    Posts
    1,192

    Re: VBA to auto filter to separate worksheets?

    Man, idk, I literally downloaded, opened, hit clear contents, then hit run filter, and it moves everything to the pay file, but either way. I closed out without saving, re-opened and went straight to the grand total and other tabs. All blank. Sorry!

    Edit* WTF, I just reopened your file and ran it and it worked on that data. I am going to try some other data and see!!
    Last edited by taylorsm; 08-26-2016 at 10:21 AM.

  14. #14
    Forum Contributor
    Join Date
    01-09-2016
    Location
    USA,USA
    MS-Off Ver
    2016
    Posts
    1,192

    Re: VBA to auto filter to separate worksheets?

    Hey jomili, Thanks! A few issues I think though. If you take the below data and put into your sheet, it says the SSN is 945632187, but should be 367894512, (comes after the S in the data).

    FAG605S3678945120000102297491120160819201608190000000498372RHP20160820999999WO000231090727AG605PC
    Also, i'm not seeing what I originally was hoping for, maybe I am missing it. But it seems that you still have to manually filter the Source sheet and copy that data over to the Filter sheet? It looks like you could even reduce yours to one page right? basically copy that yellow table over to the source file. Because the filter sheet doesn't do anything that the formulas on Source don't do as well right?

    What my goal and hope is, that I can get this to be basically fool proof. That all someone has to do is copy and paste that data into one column on the source sheet and then if it starts with FA*, then to look at that reason code and copy over to the corresponding worksheet and then sum those amounts.

    Copy/Paste into Source>IF begins FA* look at (RH,VO,WG,NSF,CN) and copy to worksheet with same name then autosum.

    *edit, Hey i was looking at it again and my column G has no formula, it just has WG in it. I know it is something like..
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    but I think maybe some of my data has one character short because of me anonymizing it
    Last edited by taylorsm; 08-26-2016 at 10:29 AM.

  15. #15
    Forum Contributor
    Join Date
    01-09-2016
    Location
    USA,USA
    MS-Off Ver
    2016
    Posts
    1,192

    Re: VBA to auto filter to separate worksheets?

    Ah, nevermind. Disregard this post. Idk how to delete though.
    Last edited by taylorsm; 08-26-2016 at 10:53 AM.

  16. #16
    Registered User
    Join Date
    12-14-2012
    Location
    Czech Republic
    MS-Off Ver
    Excel 2010
    Posts
    92

    Re: VBA to auto filter to separate worksheets?

    Quote Originally Posted by taylorsm View Post
    Man, idk, I literally downloaded, opened, hit clear contents, then hit run filter, and it moves everything to the pay file, but either way. I closed out without saving, re-opened and went straight to the grand total and other tabs. All blank. Sorry!

    Edit* WTF, I just reopened your file and ran it and it worked on that data. I am going to try some other data and see!!
    Hello taylorsm,

    the button Clear contents is there for cleaning the filter off (remove data from helper sheets). I tested again and works well at my side. Of course I don't know if that total is correct or not.

    I uploaded a ver2 with only one change: I moved buttons to the last sheet. It is more obvious here that something happened after button is pressed.

    This is what I get when I hit Run Filter:
    GrandTotal.PNG

    And this is how sheet VO looks like:
    VO.PNG

    Hope this will help you

    sysss
    Attached Files Attached Files
    Last edited by sysss; 08-26-2016 at 12:06 PM. Reason: misspelling

  17. #17
    Forum Contributor
    Join Date
    01-09-2016
    Location
    USA,USA
    MS-Off Ver
    2016
    Posts
    1,192

    Re: VBA to auto filter to separate worksheets?

    Man, I think we are golden! I can look at formulas in the future so someone not as advanced can make adjustments if necessary but for the immediate future this is perfect.

    In fact, here is the funny part, I went through several old files, and the numbers were off so I was freaking out, like wtf am I doing wrong or whats wrong with the code, the data is good blah blah. Turns out, our IT people that were responsible were sending it out incorrectly. They were not copying the formula down far enough. Months of files! And i'm talking about people with so many letters on their resumes for certificates and proficient software, and they overlooked something so simple.

    I'll keep plugging in some data and verifying but the 2-3 that I did looked good.

+ 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. Advanced Filter to Separate Sheet & Auto Updating
    By JesseWallis in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 01-30-2015, 04:36 PM
  2. Macro to filter data in to separate worksheets
    By Nicola86 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-04-2012, 02:02 PM
  3. Combobox - Filter auto-filter worksheets (ActiveX)
    By Darms in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-18-2011, 11:33 AM
  4. Macro to filter data to separate worksheets
    By rushdenx1 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-16-2010, 06:28 AM
  5. Advanced Filter from 2 separate worksheets
    By stevedes7 in forum Excel General
    Replies: 4
    Last Post: 12-28-2009, 12:20 AM
  6. Macro to auto-email separate worksheets of same workbook to separate recipients?
    By Sean Anderson in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-09-2007, 09:51 PM
  7. Auto-create separate worksheets...
    By craig72 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-19-2006, 02:50 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