+ Reply to Thread
Results 1 to 1 of 1

VBA code to create a Pivot Table from different ranges

  1. #1
    Registered User
    Join Date
    04-18-2016
    Location
    Spain
    MS-Off Ver
    2013
    Posts
    19

    VBA code to create a Pivot Table from different ranges

    I would like a VBA code (or if necessary other solution) that makes a Pivot Table.

    But, the data are on different ranges in the same worksheet. For example (see picture 1 below this post) I have 3 groups of data (red, blue and green: this colors are not important, I use it for this example). Every group has 5 fields (Product, Price, Discount, Localization and Units). And every group has 4 rows.

    So, I would like a VBA code that makes a new Pivot Table in another sheet (on the same Excel document) as I show on picture 2 (below this post) with all the available fields, as I show with a red square.

    This is just an example, so, I would like a flexible code that detect more groups, fields and rows. For example if someday I add another fill called “year” (see picture 3 below this post) I would like that the VBA code detects this new field. Or also if I need to add more groups, like the orange one that I show on picture 3 or even if I add more rows (again see picture 3).

    I uploaded 3 excel files
    file-picture 1.xlsx (contains the data that I show on picture 1)
    file-picture 2.xlsx (contains the Pivot Table that I show on picture 2)
    file-picture 3.xlsx (contains the data that I show on picture 3)

    Thank you so much!


    picture 1-2-3.jpg
    Attached Files Attached Files

+ 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] Create a Pivot Table from 3 Name Ranges
    By myobreportguru in forum Excel Charting & Pivots
    Replies: 4
    Last Post: 07-21-2016, 08:28 PM
  2. How to create date RANGES in pivot table report filter?
    By TylerB2 in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 04-28-2015, 03:34 PM
  3. [SOLVED] Create code to update named ranges in a table. Table contains Many Name Ranges
    By Calio in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-09-2014, 11:13 AM
  4. 2007 create Pivot Table VBA (old 2003 code)
    By mlgill in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-10-2011, 01:25 PM
  5. Code to create text pivot table
    By MoreSpeed in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-13-2009, 02:09 PM
  6. Create Pivot Table Using Code
    By S Jackson in forum Excel General
    Replies: 8
    Last Post: 09-01-2005, 12:05 PM
  7. [SOLVED] Create a pivot table via VBA code
    By MChrist in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-11-2005, 03:05 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