+ Reply to Thread
Results 1 to 5 of 5

VBA to Create a Pivot with Unique Name

  1. #1
    Registered User
    Join Date
    01-21-2013
    Location
    Decin
    MS-Off Ver
    Excel 2010
    Posts
    28

    VBA to Create a Pivot with Unique Name

    Hi Guys,
    I need to be able to create a pivot anytime I hit CTRL + SHIFT + P into an active cell. I recorded the procedure, changed the destination to "ActiveCell" but now the problem is that the pivot name is static.

    I need the code to create the pivot under a name which does not exist in the workbook yet...

    The code I have now:
    Please Login or Register  to view this content.
    This will create a pivot with name PivotTable20, however when I hit CTRL SHIFT P next time, I will not be able to create the pivot, because the name is already used...

    Thoughts?
    Last edited by dan.zrust; 09-24-2014 at 11:04 AM.

  2. #2
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: VBA to Create a Pivot with Unique Name

    You can leave out the TableName argument and Excel will automatically assign the next available name to it.
    Remember what the dormouse said
    Feed your head

  3. #3
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,623

    Re: VBA to Create a Pivot with Unique Name

    If you do not delete PT's you could try:

    Please Login or Register  to view this content.
    PS. Edit your post using code tags to comply with http://www.excelforum.com/forum-rule...rum-rules.html

    Edit: skiping TableName is by far smarter than mine proposition
    Last edited by Kaper; 09-24-2014 at 08:48 AM.
    Best Regards,

    Kaper

  4. #4
    Registered User
    Join Date
    01-21-2013
    Location
    Decin
    MS-Off Ver
    Excel 2010
    Posts
    28

    Re: VBA to Create a Pivot with Unique Name

    One more thing guys.

    Lets I want the new pivots to have always one pivot field in filter preset. How do I do that? Referencing to active pivot?

    I tried this:
    Please Login or Register  to view this content.
    But thats not working.

    Daniel

  5. #5
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: VBA to Create a Pivot with Unique Name

    Like this:
    Please Login or Register  to view this content.

+ 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: 0
    Last Post: 07-25-2013, 05:24 PM
  2. [SOLVED] create list of unique staff numbers with unique work codes
    By shaz0503 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 01-01-2013, 08:57 PM
  3. Replies: 7
    Last Post: 05-17-2012, 03:08 AM
  4. Replies: 0
    Last Post: 03-22-2012, 08:44 PM
  5. Replies: 3
    Last Post: 09-30-2011, 04:35 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