+ Reply to Thread
Results 1 to 2 of 2

Error in macro coding for Creating pivot

  1. #1
    Registered User
    Join Date
    09-20-2013
    Location
    New Delhi, India
    MS-Off Ver
    Excel 2010
    Posts
    12

    Error in macro coding for Creating pivot

    Hey!

    I am getting an error while running the code mentioned below to create a dynamic pivot....

    Let me know if anyone can help me....

    <code>
    Range("A1").Select
    ActiveWorkbook.Names.Add Name:="Pivot", RefersToR1C1:= _
    "=OFFSET(Data!R1C1,0,0,COUNTA(Data!C1),COUNTA(Data!R1))"
    ActiveWorkbook.Names("Pivot").Comment = ""
    Sheets.Add
    ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
    "Pivot", Version:=xlPivotTableVersion14).CreatePivotTable TableDestination _
    :="Audits!R3C1", TableName:="PivotTable2", DefaultVersion:= _
    xlPivotTableVersion14
    Sheets("Audits").Select
    Cells(3, 1).Select
    ActiveSheet.PivotTables("PivotTable2").AddDataField ActiveSheet.PivotTables( _
    "PivotTable2").PivotFields("Report ID"), "Count of Report ID", xlCount
    With ActiveSheet.PivotTables("PivotTable2").PivotFields("Business Unit")
    .Orientation = xlRowField
    .Position = 1
    End With
    End Sub
    </code>
    Last edited by vkaushal; 09-25-2013 at 02:16 PM.

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2406 Win 11 Home 64 Bit
    Posts
    24,027

    Re: Error in macro coding for Creating pivot

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here



    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

+ 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] Change default chart in a macro to prevent run time error when creating a pivot charts
    By herbie226 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-14-2013, 10:01 AM
  2. Error when creating Pivot table from macro
    By tinge89 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-16-2013, 11:04 AM
  3. error in creating pivot table in C#
    By ajz in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-13-2012, 01:20 PM
  4. Excel 2007 : Macro coding Run-time error '91'
    By smijimmy in forum Excel General
    Replies: 0
    Last Post: 07-22-2010, 07:03 PM
  5. Error in VBA Coding in Macro
    By Pooja in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-09-2006, 12:10 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