+ Reply to Thread
Results 1 to 17 of 17

Get type mismatch error when trying to create pivot table

  1. #1
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,712

    Get type mismatch error when trying to create pivot table

    Hi all,

    Background:
    Using excel 2007.
    Data file has ~ 85,000 rows of data.
    Data file has ~ 20 columns of data.

    I am getting a type mismatch error when i try to create the pivot table using the following vba code:
    Please Login or Register  to view this content.
    i thought this was strange to get a failure here because i had used this code before in other files.

    The file size was rather large and was taking awhile to finish so i decided to reduce the input file size just so i could troubleshoot file quicker.

    Turns out..............i dont get the error when i reduce the number of rows from ~85,000 to 53000. Kept number of cols the same....

    So the code shown above works but not when the number of rows is ~ 85,000...........

    Any one have an idea whats going on?

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: Get type mismatch error when trying to create pivot table

    Can we see the rest of the code, or a sample workbook?
    If posting code please use code tags, see here.

  3. #3
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,712

    Re: Get type mismatch error when trying to create pivot table

    here is the code in that procedure.............

    note: if its crucial that you have the workbook as well i may be able to do this but its going to take me some time to alter the data so that i can post it.

    note: i am posting code in this enclosed excel file......i tried to post it directly but had some issue...so decided to post to file.
    Attached Files Attached Files

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: Get type mismatch error when trying to create pivot table

    You don't need to upload the actual workbook.

    Try creating a cut down version of it, say with only 100 rows of data or so - just enough so we can run the code.

  5. #5
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,712

    Re: Get type mismatch error when trying to create pivot table

    norie,

    when i reduce the number of rows .....macro runs just fine.

    its when the input file has ~ 85k rows that i have a rpoblem. I am searching other threads and from what i have found thus far there may be a limitation using my create pivot method............not sure though

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: Get type mismatch error when trying to create pivot table

    Can you post a file with a reduced no of rows?

  7. #7
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,712

    Re: Get type mismatch error when trying to create pivot table

    i can but not sure how this helps............its going to take me a little while to alter the data file to remove sensitive information.

  8. #8
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: Get type mismatch error when trying to create pivot table

    It might help us recreate the problem which in turn might help finding a solution.

  9. #9
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,712

    Re: Get type mismatch error when trying to create pivot table

    hi norie,
    but i thought i identified the problem............its the number of rows?

  10. #10
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: Get type mismatch error when trying to create pivot table

    So this is solved then?

  11. #11
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,712

    Re: Get type mismatch error when trying to create pivot table

    norie, no this is not solved.......

    the problem as best i can tell is the number of rows............i dont know why and i dont have a soln to the problem. i was hoping you would or at least point me in the right direction.......

    i am enclosing the input test file per your request.
    Attached Files Attached Files

  12. #12
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,712

    Re: Get type mismatch error when trying to create pivot table

    ok.....found this info from another site

    HTML Code: 

    i tried what this site suggested and it worked........no mimatch runtime error

    To get it to work i did the following:
    Removed this code:
    Please Login or Register  to view this content.
    replaced above code with this code:
    Please Login or Register  to view this content.

    Now the author of this post said the following:
    '***
    The limit occurs when trying to pass a Range object with greater than 65536 rows (max number of rows for xl2003), even if you are using xl2007 or xl2010.
    The SourceData argument, which is a Variant type, handles either Range objects or Strings representing Range Address references below this limit.
    For Ranges greater than 65536 rows, it appears to only work with Address References and not Range Objects.
    A workaround for your code would be to convert the Range object into an Address reference.
    '***

    i dont understand this.......can someone help explain this to me?

  13. #13
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: Get type mismatch error when trying to create pivot table

    It means you can either use a range that refers to the source data or the address of the source data.

    I actually thought you could only pass the address and was going to suggest that if data_range was a range use it's Address property.

  14. #14
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,712

    Re: Get type mismatch error when trying to create pivot table

    norie,

    i dont understand why my approach does not work and i dont understand why what they did does work.............

  15. #15
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: Get type mismatch error when trying to create pivot table

    Have you tried using the address instead of the range?

    Like I said that's what I thought you were supposed to use, not the range.

  16. #16
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,712

    Re: Get type mismatch error when trying to create pivot table

    when i use the range when there are too many rows ......... i get the type mismatch error.

    when i use the address it works in all cases..........

    does anyone know why?

  17. #17
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: Get type mismatch error when trying to create pivot table

    It might be some sort of bug, perhaps version related.

    I haven't see anything about that though.

    Why not just use the address all the time since it works no matter the no of rows?

+ 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. Complile Error: Type Mismatch ??? After adding error trap
    By clemsoncooz in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-22-2012, 03:50 PM
  2. Conditional Formatting - Run Time Error '13' Type Mismatch Error
    By ksp in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-17-2011, 07:37 PM
  3. Type Mismatch on Pivot Table creation
    By jomili in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-10-2011, 04:51 PM
  4. [SOLVED] Pivot Table type mismatch
    By Bill in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-18-2006, 08:35 PM
  5. Help: Compile error: type mismatch: array or user defined type expected
    By lvcha.gouqizi in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-31-2005, 05:05 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