+ Reply to Thread
Results 1 to 4 of 4

Creating a Pivot Table using VBA

  1. #1
    Registered User
    Join Date
    06-28-2013
    Location
    Nashville, TN
    MS-Off Ver
    Excel 2010
    Posts
    7

    Creating a Pivot Table using VBA

    Ok, so I have spent way too much time trying to figure this one out, so I'm turning to the experts! I am trying to create a macro that will take a selection of data, name it "Data", then use that selection as the source for my pivot table. Here is my code and I receive a Run-time 424: Object Required error at the bolded section...Can someone please tell me what I'm missing? Thanks in advance!

    Please Login or Register  to view this content.

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,333

    Re: Creating a Pivot Table using VBA

    Hi tbone3,

    I'd start by using a Dynamic Named Range for the data to be used in the Pivot Table. See:
    http://www.ozgrid.com/Excel/DynamicRanges.htm or
    http://www.bettersolutions.com/excel...G820716330.htm

    Then use the Named Range for the data in your pivot.

    Hope that helps you write better code.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Registered User
    Join Date
    06-28-2013
    Location
    Nashville, TN
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Creating a Pivot Table using VBA

    @MarvinP : Why doesn't what I have in there now work (see code below)? I don't see how this addresses the pivot cache question? I apologize- I'm new at using vba to create pivot tables.

    Please Login or Register  to view this content.
    Last edited by tbone3; 10-16-2013 at 03:48 PM.

  4. #4
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,990

    Re: Creating a Pivot Table using VBA

    If you are using 2010, it's simpler to use a Table, which works like a dynamic named range automatically.
    Everyone who confuses correlation and causation ends up dead.

+ 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: 08-09-2013, 12:32 PM
  2. creating Pivot table
    By kitrak2 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-03-2013, 12:58 AM
  3. [SOLVED] Creating Pivot Table
    By asifamanulla in forum Excel Charting & Pivots
    Replies: 4
    Last Post: 02-04-2013, 08:14 AM
  4. Creating a table/array from Pivot Table
    By Roktgr in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-22-2010, 07:02 PM
  5. Creating a Pivot Table using VBA
    By Inzuri in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-29-2008, 12:37 PM

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