+ Reply to Thread
Results 1 to 5 of 5

Creating pivot table with Recorded Macro

  1. #1
    Registered User
    Join Date
    09-18-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    47

    Creating pivot table with Recorded Macro

    I have a macro that creates a PivotTable and it works great. The only issue is that it creates the pivot table by calling "Sheet2". If I try to do it again, within the document it gets an error because the next sheet will be sheet3 or sheet4 depending on what other macro has been run.
    Please Login or Register  to view this content.
    The section in question is:
    Please Login or Register  to view this content.
    I am trying to figure out if I can make it just use the next sheet in line weather it is Sheet2 or Sheet102.

    Thanks for any help.

  2. #2
    Valued Forum Contributor marreco's Avatar
    Join Date
    07-02-2011
    Location
    Brazil
    MS-Off Ver
    Excel 2010
    Posts
    1,862

    Re: Creating pivot table with Recorded Macro

    Hi.

    Reading here
    http://www.databison.com/pivot-table...able-in-excel/
    http://www.globaliconnect.com/excel/...79&Itemid=475:)
    "No xadrez nem sempre a menor dist?ncia entre dois pontos ? uma linha reta" G. Kasparov.

    If your problem is solved, please say so clearly, and mark your thread as Solved: Click the Edit button on your first post in the thread, Click Go Advanced, select b from the Prefix dropdown, then click Save Changes. If more than two days have elapsed, the Edit button will not appear -- ask a moderator to mark it.

  3. #3
    Registered User
    Join Date
    09-18-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    47

    Re: Creating pivot table with Recorded Macro

    The pivot table is created fine with the code that I have, I just need to know how to change the code so that it doesn't require Sheet2. It will use whatever sheet is next in line.

  4. #4
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Creating pivot table with Recorded Macro

    It is not good idea to run the PT on active sheet, but if you want, you can replace
    Sheets("Sheet2").Select
    with

    ActiveSheet.Select which means your cursor has to be on the active sheet before you run the code.

  5. #5
    Registered User
    Join Date
    09-18-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    47

    Re: Creating pivot table with Recorded Macro

    That also will not fix the issue, does anyone know how to reset the Sheet.Count? I have a reset button in my workbook, if i can add to that some code that will reset the sheet count back to sheet1 then this issue will be resolved....sort of

+ 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] Recorded Pivot Table Macro Doesn't Do What I Recorded!
    By diakonos1984 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-26-2013, 11:01 AM
  2. Creating two pivot tables on same sheet - Optimize recorded macro code
    By johnny_tc in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-07-2012, 11:59 AM
  3. [SOLVED] Error in a recorded macro to create Pivot Table
    By aadeshgandhi in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-21-2012, 12:40 PM
  4. Recorded macro for Pivot Table
    By jackman in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-12-2009, 05:16 PM
  5. Recorded Macro with Pivot table
    By Eladamri in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-31-2008, 09:04 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