+ Reply to Thread
Results 1 to 2 of 2

Creating macro to create 2 worksheets from a pivot table and move them to a new workbook

  1. #1
    Registered User
    Join Date
    08-31-2012
    Location
    Denver
    MS-Off Ver
    Excel 2007
    Posts
    3

    Creating macro to create 2 worksheets from a pivot table and move them to a new workbook

    Hi there. First time poster. I'm having some trouble.



    I am trying to save myself from needless busy work by creating a macro. I am starting with a workbook that contains 2 pivot tables created from 2 large data fields. I need to create individual tables from this for each individual person in these data sets. I have been trying to create a macro that creates a new empty workbook, then creates the sheet I need from the first pivot, moves the sheet to the new workbook, renames the sheet, creates the sheet I need from the second pivot, moves the second sheet to the new workbook, renames the second sheet. And I need the macro to be relative so when I try to duplicate for each of the people lower on the list everything carries over appropriately.


    The process in excel looks like this:

    File->new->workbook

    Active workbook->first pivot table->double click cell J5

    right-click new sheet->move or copy->select new workbook

    right-click new sheet now in new workbook->rename->"payments"

    return to first active workbook->second pivot table->double click cell J5

    right-click second new sheet->move or copy->select new workbook

    right-click second new sheet now in new workbook->rename->"payments 2"


    The cell J5 needs to be relative, so that the macro will work for J6, J7, etc.


    The macro I've been trying to create myself (I have no VBA experience at all):
    Please Login or Register  to view this content.
    this results in runtime error '9'; subscript out of range

    I also have the 'use relative references' selected, and I'm using excel 2007 if it matters.

    Any help/advice/insight you can provide would be greatly appreciated. It seemed so easy to do this at first, but now I've been banging my head against this solution for far too long. Help me internets, you're my only hope.
    Last edited by Cutter; 08-31-2012 at 09:52 PM. Reason: Added code tags

  2. #2
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Creating macro to create 2 worksheets from a pivot table and move them to a new workbo

    @ V3rse

    Welcome to the forum.

    Please notice that code tags have been added to your post(s). The forum rules require them so please keep that in mind and add them yourself whenever showing code in any of your future posts. To see instructions for applying them, click on the Forum Rules button at top of the page and read Rule #3.
    Thanks.

+ 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