+ Reply to Thread
Results 1 to 4 of 4

Create Pivot Table Macro - Working In One Workbook But Not Another?

  1. #1
    Registered User
    Join Date
    10-27-2012
    Location
    Uk
    MS-Off Ver
    Excel 2010
    Posts
    98

    Question Create Pivot Table Macro - Working In One Workbook But Not Another?

    Hi All

    I've been puzzling over this for the last 2 days but I am truly stuck.
    I have the following piece of code which creates a pivot table from the data on a new sheet

    Please Login or Register  to view this content.
    It works perfectly in workbook 'Create Pivot VBA Test.xlsm.
    But I'm getting a run time error in 'NEW SLA v6.21 (no data).xlsm'

    The code and sheet names are the same in both, so I can't figure out why I'm getting an error in one an not the other??

    Any help/advice greatly appreciated
    Many thanks
    Vicky
    Attached Files Attached Files

  2. #2
    Forum Expert nankw83's Avatar
    Join Date
    08-31-2015
    Location
    Kuwait
    MS-Off Ver
    365
    Posts
    1,712

    Re: Create Pivot Table Macro - Working In One Workbook But Not Another?

    Hi Vicky,

    The issue is in your SLA file, you have data in rows 1 & 2 so when you use A3.CurrentRegion is considers row #1 as the header row & in some columns you don't have data & thus you can't make a pivot table. To see what I mean, you can run the below code & see what is selected

    Please Login or Register  to view this content.

    To fix your issue, try to change your code to the below referencing the table name directly

    Please Login or Register  to view this content.
    If I was able to help, you can thank me by clicking the * Add Reputation under my user name

  3. #3
    Registered User
    Join Date
    10-27-2012
    Location
    Uk
    MS-Off Ver
    Excel 2010
    Posts
    98

    Re: Create Pivot Table Macro - Working In One Workbook But Not Another?

    Fantastic. Thank you
    I swear this forum keeps me in a job!

    All the best
    V

  4. #4
    Forum Expert nankw83's Avatar
    Join Date
    08-31-2015
    Location
    Kuwait
    MS-Off Ver
    365
    Posts
    1,712

    Re: Create Pivot Table Macro - Working In One Workbook But Not Another?

    Glad to help & thanks for the reps

+ 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] Require VBA Code for create Pivot table in New Workbook
    By sbvaram in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-18-2020, 12:28 AM
  2. Replies: 1
    Last Post: 09-01-2017, 07:24 AM
  3. How to create a dynamic macro that will create pivot table
    By thlee1122 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-08-2015, 11:49 PM
  4. Create a macro to create a pivot table in a worksheet
    By Triscia in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-15-2015, 10:53 AM
  5. how to create a pivot table in another workbook??
    By NeoDasari in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 04-23-2015, 01:33 PM
  6. Create a Pivot Table referencing the data from another workbook (VBA)
    By kenjiventurina in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-09-2013, 05:24 AM
  7. Replies: 1
    Last Post: 08-31-2012, 09:52 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