Results 1 to 2 of 2

VBA Error - Pivot Table

Threaded View

  1. #1
    Registered User
    Join Date
    12-18-2015
    Location
    NZ
    MS-Off Ver
    2003
    Posts
    1

    VBA Error - Pivot Table

    Hi

    I am trying to generate a pivot table but I keep getting a "type mismatch" error. Code I use is:

    Worksheets("O").Activate
    Range("A1").Select
    Range(Selection, Selection.End(xlDown)).Select
    Range(Selection, Selection.End(xlToRight)).Select
    Set myRng = Selection

    Worksheets("Generate").Activate

    Set tableRange = Range(ActiveCell, ActiveCell.Offset(0, 0))
    ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, _
    SourceData:=myRng, Version:=xlPivotTableVersion12).CreatePivotTable _
    TableDestination:=tableRange, TableName:="PivotTable4", DefaultVersion _
    :=xlPivotTableVersion12


    I have noticed that changing "SourceData:=myRng" to actual range (e.g. SourceData:="O!A1:R1000" works. However, I have been able to generate the pivot table successfully with the above code for several other files. I can't figure out why this one is generating an error.
    Last edited by mehc011; 12-18-2015 at 09:15 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Need error handler code to avoid pivot table refreshing error if no data is available
    By adelkam in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-04-2015, 12:37 PM
  2. Error with pivot items in pivot table
    By cool1_boy1 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-29-2015, 10:57 AM
  3. VBA: Pivot Tables / Error 1004: Pivot Table Not Valid
    By vidyuthrajesh in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-22-2013, 03:54 PM
  4. [SOLVED] VBA Pivot table error
    By amotto11 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-22-2013, 01:05 PM
  5. Pivot table error message but can't find the offending pivot table
    By dcoates in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 01-22-2013, 08:45 AM
  6. Pivot table and Pivot Chart - Run time error 5
    By yogananda.muthaiah in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-30-2012, 08:35 AM
  7. Replies: 3
    Last Post: 03-26-2008, 07:34 PM

Tags for this Thread

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