+ Reply to Thread
Results 1 to 4 of 4

How to set up Pivot table in VBA

  1. #1
    Registered User
    Join Date
    07-21-2015
    Location
    us
    MS-Off Ver
    10
    Posts
    1

    How to set up Pivot table in VBA

    Hi,

    I'm trying to simply create a pivot table using VBA. However, the number of rows is unknown and changes each time the program is run. To counter this, so that my macro selects the entire dataset, I've been attempting to set my range equal to a variable and then plugging the variable into the SourceData.

    my headings are in Ranges(A1:E1), so I've been selecting A1, end(xlright) to select all the columns, then end(xldown) to select all the rows. Then setting the selection equal to the variable pivotrange. below is a snip of my code.

    I'm about to throw my laptop out the window... so I would really appreciate any help you can offer.

    Please Login or Register  to view this content.
    Last edited by FDibbins; 07-21-2015 at 11:47 PM.

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: How to set up Pivot table in VBA

    Hi, welcome to the forum

    I have adjusted your title to something that better describes your problem, and wrapped code tags around your code (see my signature on how to do that)
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: How to set up Pivot table in VBA

    i wouldnt normally use the method you have for determining pivot range...its rather unpredictable
    nevertheless..possible code below

    Please Login or Register  to view this content.
    im assuming sector exposure worksheet...doesnt exist
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  4. #4
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: How to set up Pivot table in VBA

    Please Login or Register  to view this content.
    method if sector exposure already exist

    as you did not indicate if you wanted anything else
    both methods do not add anything (no fields/rows/columns/filters/values) to the pivot table...just set it up

+ 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. [SOLVED] 15 hours processor time to delete my mistake :(. Multi-threaded deleting in vba?
    By motivef in forum Excel Programming / VBA / Macros
    Replies: 22
    Last Post: 07-23-2012, 12:24 PM
  2. made a stupid mistake... locked up workbook on initialize
    By smokebreak in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-09-2011, 12:42 PM
  3. Summing values for past 24 hours
    By bobhearn11 in forum Excel General
    Replies: 2
    Last Post: 01-08-2010, 04:03 AM
  4. Adding past 24 hours
    By CaimanReid in forum Excel General
    Replies: 2
    Last Post: 08-20-2009, 10:55 AM
  5. Replies: 1
    Last Post: 08-01-2009, 06:45 AM
  6. count hours past midnight
    By cojast in forum Excel General
    Replies: 3
    Last Post: 07-01-2008, 03:53 PM
  7. [SOLVED] Found Mistake can't correct.
    By dvonj in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 03-21-2005, 05:06 PM
  8. [SOLVED] totaling times past 24 hours
    By txduster in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-21-2005, 01:06 PM

Tags for this Thread

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