+ Reply to Thread
Results 1 to 15 of 15

VBA Pivot Fields Filtering

  1. #1
    Forum Contributor
    Join Date
    09-11-2013
    Location
    Huntsville, AL
    MS-Off Ver
    Excel 2007
    Posts
    180

    VBA Pivot Fields Filtering

    Please Login or Register  to view this content.
    Last edited by greggpetersen75; 09-12-2013 at 09:58 AM.

  2. #2
    Forum Contributor
    Join Date
    09-11-2013
    Location
    Huntsville, AL
    MS-Off Ver
    Excel 2007
    Posts
    180

    Re: Easier way to write this?

    Thank you Fotis, I made the updates you suggested and am reading the rules. :-)

  3. #3
    Forum Contributor
    Join Date
    09-11-2013
    Location
    Huntsville, AL
    MS-Off Ver
    Excel 2007
    Posts
    180

    Re: Easier way to write this?

    Is there a simpler way to construct this With statement?

  4. #4
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: VBA Pivot Fields Filtering

    edit: question now added

    perhaps
    Please Login or Register  to view this content.
    Last edited by JosephP; 09-12-2013 at 10:05 AM.
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  5. #5
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: VBA Pivot Fields Filtering

    Quote Originally Posted by JosephP View Post
    it's not in the rules but you may wish to add an actual question to your post ;-)
    .............


    @ greggpetersen75


    I believe that you need to describe a little what you want to do as JosephP mentioned!
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

  6. #6
    Forum Contributor
    Join Date
    09-11-2013
    Location
    Huntsville, AL
    MS-Off Ver
    Excel 2007
    Posts
    180

    Re: VBA Pivot Fields Filtering

    Thank you JosephP, that worked perfectly

  7. #7
    Forum Contributor
    Join Date
    09-11-2013
    Location
    Huntsville, AL
    MS-Off Ver
    Excel 2007
    Posts
    180

    Re: VBA Pivot Fields Filtering

    Please Login or Register  to view this content.
    So I know this is a lot, and it works, but I was wondering if you were to code this would you construct it like this, or would you do something else? I am trying to learn to code like a pro.

  8. #8
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: VBA Pivot Fields Filtering

    I am no pro but I would write it like this
    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    09-11-2013
    Location
    Huntsville, AL
    MS-Off Ver
    Excel 2007
    Posts
    180

    Re: VBA Pivot Fields Filtering

    Joseph,

    I will definitly check that out! A couple of questions:
    1. What does this command do:
    Please Login or Register  to view this content.
    2. Can you make it so that you can recycle that code? So if I was going to do 3 similiar Pivot Tables and I just wanted to change the data, "TimeKeepingDataTbl" or what would really be cool is somehow based on the Sub calling a Private Sub with this Pivot Table data, and some variants (depending on the Sub) containing this Macro I could change the variables within the Pivot Table.
    For Example: If for Sub 1 I wanted the Pivot Expression to say:
    Please Login or Register  to view this content.
    But if Sub 2 called on the Pivot Table Private Sub the code would look like:
    Please Login or Register  to view this content.
    There is probably an If Statement that could do that, or is it just easier to copy and paste the pivot language for each Sub routine and make the tweaks for each one?

  10. #10
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: VBA Pivot Fields Filtering

    1 prevents the pivot table from trying to update while you are manipulating it
    2 if you have common code you can put that into a routine and call it but in my experience there is rarely a case for a generic routine to create a pivot table-I do use several for applying formats or rearranging the layout of existing tables though
    3 my name is actually Josie not Joseph :-) (or Josephine when I'm in trouble)

  11. #11
    Forum Contributor
    Join Date
    09-11-2013
    Location
    Huntsville, AL
    MS-Off Ver
    Excel 2007
    Posts
    180

    Re: VBA Pivot Fields Filtering

    Thanks Josie!! I hope I am not boring you with my questions. I really want to do this the right way.

  12. #12
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: VBA Pivot Fields Filtering

    not at all-I wish my kids were as eager to learn! ;-)

  13. #13
    Forum Contributor
    Join Date
    09-11-2013
    Location
    Huntsville, AL
    MS-Off Ver
    Excel 2007
    Posts
    180

    Re: VBA Pivot Fields Filtering

    So, I have x amount of records on Data worksheet. Part of my macro is to append records to this data worksheet on a monthly basis.
    I do not want them to double append the data. So right now I run a macro to determine it by Pivoting on the Department (DRange) and the Month (MRange). If the user records are greater than 1 (I have a dummy record there), then I know the user, already appended the records once, so I run a routine that filters on the records based on DRange and MRange and use this command to delete the records:
    Please Login or Register  to view this content.
    There are 61 rows of dummy data including the headers.
    2 questions, is this the best way to delete the records for the repaste, and is there a better way to count the records that exist for the current department and current month, so that I don't have to create a pivot to do it?

  14. #14
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: VBA Pivot Fields Filtering

    hard to say without seeing the workbook itself but you could probably use a countifs formula to check the data before you append it in the first place

  15. #15
    Forum Contributor
    Join Date
    09-11-2013
    Location
    Huntsville, AL
    MS-Off Ver
    Excel 2007
    Posts
    180

    Re: VBA Pivot Fields Filtering

    Please Login or Register  to view this content.
    This is the code I came up with. It worked pretty well.

+ 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. Replies: 2
    Last Post: 02-17-2012, 03:08 AM
  2. Replies: 4
    Last Post: 01-20-2012, 04:50 AM
  3. [SOLVED] Easier Way?
    By scott45 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-12-2005, 12:05 AM
  4. An easier way ??
    By Fitty in forum Excel General
    Replies: 1
    Last Post: 10-08-2005, 06:05 PM
  5. There has to be any easier way!!
    By mully in forum Excel - New Users/Basics
    Replies: 18
    Last Post: 08-13-2005, 08:05 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