+ Reply to Thread
Results 1 to 2 of 2

problems in creating pivot table using VBA

  1. #1
    Registered User
    Join Date
    08-25-2019
    Location
    singapore
    MS-Off Ver
    2016
    Posts
    1

    Red face problems in creating pivot table using VBA

    I have created a vba code for creating pivot table which works in the workbook that i created this vba code but when i use this code in another workbook, there is error: subscript out of range.

    Sheets.Add ActiveSheet.Name = "Sheet2"

    ActiveWorkbook.PivotCaches.Create(SourceType:=xlExternal, SourceData:= _
    ActiveWorkbook.Connections("WorksheetConnection_Sheet1!$A:$AV"), Version:=6). _
    CreatePivotTable TableDestination:="Sheet2!R3C1", TableName:="PivotTable2" _ ,
    DefaultVersion:=6


    Sheets("Sheet2").Select Cells(3, 1).Select With
    ActiveSheet.PivotTables("PivotTable2").CubeFields( _ "[Range].[Purchase Requisition]")
    .Orientation = xlRowField .Position = 1 End With

    The third paragraph about the workbook connection is where the debugger highlights

  2. #2
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,907

    Re: problems in creating pivot table using VBA

    Most likely cause is that you don’t have a connection with that name (perhaps a misspelling).
    Rory

+ 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. Replies: 1
    Last Post: 07-29-2015, 05:19 PM
  2. Replies: 1
    Last Post: 07-29-2015, 05:15 PM
  3. [SOLVED] Need Help Creating Random Multiplication Table Problems For My Son
    By ebrew in forum Excel - New Users/Basics
    Replies: 16
    Last Post: 08-13-2013, 07:22 AM
  4. [SOLVED] Problems with sorting andf Pivot Table problems
    By Saturn in forum Excel General
    Replies: 4
    Last Post: 10-07-2012, 07:47 AM
  5. Problems creating a Pivot Table
    By msmith5401 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-05-2009, 05:12 PM
  6. [SOLVED] Pivot Table problems
    By Randy Starkey in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-30-2005, 10:25 PM
  7. I am having problems creating pivot table of data
    By wyman in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 01-12-2005, 02:06 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