+ Reply to Thread
Results 1 to 5 of 5

Trying to create a pivot table with a macro

  1. #1
    Forum Contributor
    Join Date
    06-25-2013
    Location
    Longview, TX
    MS-Off Ver
    MS365
    Posts
    338

    Trying to create a pivot table with a macro

    Hello all!

    I'm trying to create 2 pivot tables on a spreadsheet; both tables will use the same data. This would probably be going better if I had a good handle on pivot tables, but I still had delusions of creating this macro without help. That plan has failed.
    I've tried and tried to get my brain wrapped around the darn tables without success. Reading instructions does me no good; I need to be hands on and nobody around here knows anything about them either!

    So, anyway, with that said - I tried recording a macro to create the 2 tables needed but, of course, it didn't work. I've been Googling the better part of the afternoon and keep altering and tweaking the code, just trying to get it to create ONE of the tables, thinking I'd move on from there. I've made such a mess of the code that it's not recognizable anymore, so I've trashed it.

    I'm attaching a very shortened version of what's needed. Basically, I need to select A-R and down to the last row, sort by M, then make the tables. The first one needs to start in U2, having U showing the DIVISION and T showing the count of lines in each division. The second table needs to start in X2, having X showing the DIVISION divided by Vendor Name and Y showing the count of each vendor by division.

    I'm sure I'm over-thinking it and you all will get it right off. I have all the faith in the world in you folks!

    Thanks

    Jenny
    Attached Files Attached Files
    Last edited by zookeepertx; 10-30-2015 at 05:31 PM.

  2. #2
    Registered User
    Join Date
    09-09-2015
    Location
    India
    MS-Off Ver
    2010
    Posts
    65

    Re: Trying to create a pivot table with a macro

    Hi Jenny,

    PFB for the required code and PFA for the sample data and macro file. I hope this code helps.



    Please Login or Register  to view this content.
    Regards
    Ramandeep Singh
    Attached Files Attached Files

  3. #3
    Forum Contributor
    Join Date
    06-25-2013
    Location
    Longview, TX
    MS-Off Ver
    MS365
    Posts
    338

    Re: Trying to create a pivot table with a macro

    Hello!
    Thank you very much for your reply! I will be back at work on Monday and will give it a try then. I'll be sure to come back and let you know how it goes.

    Jenny

  4. #4
    Forum Contributor
    Join Date
    06-25-2013
    Location
    Longview, TX
    MS-Off Ver
    MS365
    Posts
    338

    Re: Trying to create a pivot table with a macro

    Sorry for being so long in getting back to you, but it's Month End here at work and I'm in the Acctg Dept, so I've been swamped.

    So, I tried your coding and it gives me part of what I need. I did have to replace DefaultVersion:=xlPivotTableVersion15 with Version 14 to get past an error message. (I'm on 2010)

    Just a couple of problems, though. I'm re-attaching my workbook to show the trouble. As before, sheet 1 shows what I need; Sheet 3 shows what your coding gives me. In the second table, the vendor names need to be oriented under the divisions, but in the same column. (See sheet 1). And the "Count of..." column (which should be column "Y") needs to be a count of each vendor within each division. Also, at the bottom of each table is a row that says (blank); can we get rid of that?

    I've been googling, tweaking, recorded and re-recorded macros trying to hit just the right wording in the code, but I'm going crazy! I'm sure you'll see what's wrong right away; definitely faster than I EVER would!

    Thanks for your help!

    Jenny
    Attached Files Attached Files
    Last edited by zookeepertx; 11-06-2015 at 05:56 PM. Reason: Because I can't speel, LOL!

  5. #5
    Forum Contributor
    Join Date
    06-25-2013
    Location
    Longview, TX
    MS-Off Ver
    MS365
    Posts
    338

    Re: Trying to create a pivot table with a macro

    Does anyone have any input on this problem? I spent about half a day on Friday trying again to get it to work correctly and got absolutely nowhere!

+ 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. How to create a dynamic macro that will create pivot table
    By thlee1122 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-08-2015, 11:49 PM
  2. How to create a macro to create a pivot table on a new sheet
    By thlee1122 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-19-2015, 11:14 AM
  3. Create a macro to create a pivot table in a worksheet
    By Triscia in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-15-2015, 10:53 AM
  4. Create 2 pivot table using macro
    By melforce in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-23-2015, 09:19 PM
  5. Macro to create pivot table/pivot chart
    By Karina in forum Excel General
    Replies: 2
    Last Post: 10-27-2011, 10:33 PM
  6. [SOLVED] macro to create a pivot table
    By Catie79 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-22-2005, 06:10 PM
  7. macro to create pivot table
    By sandeeprs77 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-13-2005, 12:57 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