+ Reply to Thread
Results 1 to 9 of 9

formatting data for pivot table

  1. #1
    Registered User
    Join Date
    10-15-2010
    Location
    san francisco
    MS-Off Ver
    Excel 2003
    Posts
    6

    formatting data for pivot table

    Hi,

    I currently have a large data set with the following multiple columns:

    Description, amount, date

    This is then repeat every 3 columns (for example it will be Description, Amount, Date1, Description, amount, Date2, etc).

    To create the pivot table i usually move all the data into 3 columns and copy/paste it one after another. So row 1 - 300 will be for the date1, then row 300-600 will be for date2, etc all in Column A, B, C.

    My question is, is there an easy way in excel to highlight all the columns and move it so it repeats itself, so that i can pivot it? I have data sets with a lot of columns and want to easily move it to a pivot friendly format so that i can trend the data.

    Edit: i added an example. The yellow data is typically how i receive my data but it's hundred of rows and a lot of columns, so i'm looking for the fastest way to manipulate it to the red format so i can pivot it. I usually spend a lot of time cutting and pasting it, but i think there has to be a better, faster, more efficient way to accomplish this in excel. Thanks!!!
    Attached Files Attached Files
    Last edited by shawzito; 10-17-2010 at 01:18 PM.

  2. #2
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: formatting data for pivot table

    Hello & Welcome to the Board,

    With your sample data how about this.

    Instead of pasting the data right below as you have it in your sample, I have it going to G1 instead. Hope this will work for you.

    Select Alt + F8 and run SetupforPivot
    Attached Files Attached Files
    HTH
    Regards, Jeff

  3. #3
    Registered User
    Join Date
    10-15-2010
    Location
    san francisco
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: formatting data for pivot table

    That's exactly what i want! I have large data set so it extends over G1. Which parameters in the macro do i need to edit so that I can adjust the range. Do you mind explaining it to me. This is the coolest thing ever and will save me so much!

    Or is there a macro where i could just highlight my data set, run the macro, and it will transpose it to the right of it. I'm going to be using this function often to trend data for work. Thank you so much Jeff.
    Last edited by shawzito; 10-16-2010 at 02:27 AM.

  4. #4
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: formatting data for pivot table

    Hi shawzito,

    Took a look at the macro again and realized one of the steps was wrong. Didn't realize it because all the 1's were masking the problem, but on the test data, changed the 1's to reflect different numbers and seems to be running right now.

    The code is commented describing what is going on so hope it helps you understand a little bit more. If you have trouble following something please let me know...could have missed something.

    So you don't have to alter the output of the data, the macro has been adjusted to output to sheet2 beginning in A1.

    Sure don't know how to make the data set work off of selecting a range at this moment, but something to look at later.

    Just as an added feature (maybe more for my learning than yours), the macro will produce a pivot table automatically. After you run the macro the first time, delete the sheet with the pt, sheet2 clear the contents, and then sheet1 add more data to the right and re-run SetupforPivot. Pivot data and the pivot table will automatically adjust to the need data.
    Attached Files Attached Files
    Last edited by jeffreybrown; 10-16-2010 at 11:15 AM.

  5. #5
    Registered User
    Join Date
    10-15-2010
    Location
    san francisco
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: formatting data for pivot table

    Hi Jeff,

    This is great. When i add additional columns that macro picks it up in the pivot table. I like the feature where it automatically creates the pivot table, that's awesome!

    I also added more rows (equity,AR - see attachments). When i add the new rows the macro doesn't automatically capture the additional rows. It captures the additional months though.

    I looked through the code and wasn't sure what needs to be adjusted. Do you mind helping me with this? I appreciate it Jeff!!!!
    Attached Files Attached Files

  6. #6
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: formatting data for pivot table

    Pretty easy fix. We need to Dim another variable (RW) so now both columns and rows are dynamic.

    Look at the .Resize part of the code...this is where the variable RW is used which resizes the copied values to the length of Sheet1 column A - 1

    I updated the comments in the code and again, hope I didn't miss anything.

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    10-15-2010
    Location
    san francisco
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: formatting data for pivot table

    That works jeff!! Appreciate all the help!!!

  8. #8
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: formatting data for pivot table

    You're most welcome

    If you are satisfied with the answer provided, please don't forget to mark the thread as solved.

    To mark your thread solved do the following:
    - Go to the first post
    - Click edit
    - Click Advance
    - Just below the word "Title:" you will see a dropdown with the word No prefix.
    - Change to Solve
    - Click Save

  9. #9
    Registered User
    Join Date
    10-15-2010
    Location
    san francisco
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: formatting data for pivot table

    Done! Can you please check your private message. I had another quick question =)

+ 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