+ Reply to Thread
Results 1 to 5 of 5

Reverse Pivot

  1. #1
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    4,062

    Reverse Pivot

    This one may be easier to understand if you open the example first. There are 2 tabs: "The Way it Is", and the "The Way it Should Be".
    The table in "the way it is" is structured like a pivot table. It represents a certain class of employees, by region, by function, and within a specific PAC (Expense group). This table is one of about 15 on a page. I would like to be able to organize the data so I can run Pivot Tables on the information, but to do that I need to change the structure of the tables to something similar to what's on the "Way it Should Be" tab.

    I can do it with a lot of manual effort, but is there an easier way to do it via VBA, for this and another simiarly structured tables I come across?

    Any help is greatly appreciated.
    Attached Files Attached Files
    Last edited by jomili; 11-23-2010 at 03:05 PM.

  2. #2
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Reverse Pivot

    Nice, it seems you are changing it from "spreadsheet format" to "database format". I'm actually working on something similar right now so I can get a bunch of data from Excel into Access easiest. Anyway, this should do. The only thing it doesn't copy over is the format. If that is a problem let me know and I can fix it, but it would almost be easier just to manually do it anyway.

    Please Login or Register  to view this content.
    Is your code running too slowly?
    Does your workbook or database have a bunch of duplicate pieces of data?
    Have a look at this article to learn the best ways to set up your projects.
    It will save both time and effort in the long run!


    Dave

  3. #3
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    4,062

    Re: Reverse Pivot

    Dave,

    You really rock! I tested your macro on my Example, and it worked perfectly.

    I went to my source, which has about 15 similar tables all lined up. I had to delete the redundant column headings, blank lines etc., and change sheet names but after that it worked. However, it doesn't seem to have caputured all of the information. Since my source, after the alterations mentioned above, has 146 lines, should I increase the values for i and j? Or, how do I increase the capability to handle more lines?

  4. #4
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Reverse Pivot

    That's right, make i the number of rows you are working on and j the number of columns.
    For example, if you had data in rows 24 - 108 you would put:

    Please Login or Register  to view this content.

  5. #5
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    4,062

    Re: Reverse Pivot

    Nice! That did the trick, exactly what I needed. Thanks so much for your help!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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