+ Reply to Thread
Results 1 to 10 of 10

Dynamic range for pivot table

  1. #1
    Registered User
    Join Date
    04-01-2009
    Location
    new delhi
    MS-Off Ver
    Excel 2003
    Posts
    45

    Dynamic range for pivot table

    I am trying to create a pivot table on a new sheet names as 4x4

    I am getting following error:
    Error : 1004
    Reference Not Valid

    I am not sure where is the problem. I have genererated this code by using macro recorder and just changed the source and destination of the pivot generation code.

    Need your help Guys!!!

    Please Login or Register  to view this content.



    Webbug

  2. #2
    Forum Expert
    Join Date
    01-03-2006
    Location
    Waikato, New Zealand
    MS-Off Ver
    2010 @ work & 2007 @ home
    Posts
    2,243

    Re: Dynamic range for pivot table

    hi


    What line errors when you step through the code a line at a time by pressing [F8]?
    I'm guessing it is the "pivotcaches.creates..." line, so I've made some modifications...
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    hth
    Rob
    Rob Brockett
    Kiwi in the UK
    Always learning & the best way to learn is to experience...

  3. #3
    Registered User
    Join Date
    04-01-2009
    Location
    new delhi
    MS-Off Ver
    Excel 2003
    Posts
    45

    Re: Dynamic range for pivot table

    Hi Rob,

    Thanks for reply.

    I am still facing an error. It is now Run time Error 13 - "Type mismatch"

    I am using following code now
    Please Login or Register  to view this content.
    Application keeps highlighting this part of code only.


    Webbug

  4. #4
    Forum Expert
    Join Date
    01-03-2006
    Location
    Waikato, New Zealand
    MS-Off Ver
    2010 @ work & 2007 @ home
    Posts
    2,243

    Re: Dynamic range for pivot table

    hi,


    Do all of the columns in the range (from column A upto & including column S) have Headers (ie text) in row 1?


    I'm sorry, I don't know what is going wrong for you...
    The below works for me in Excel 2007 (I'm on a different computer):

    Can anyone else suggest how the error can be fixed?

    Please Login or Register  to view this content.
    Rob

  5. #5
    Registered User
    Join Date
    04-01-2009
    Location
    new delhi
    MS-Off Ver
    Excel 2003
    Posts
    45

    Re: Dynamic range for pivot table

    Hi all,

    I have attached the snapshot and dummy data file..Hope this will help in trapping error.

    Webbug
    Attached Images Attached Images
    Attached Files Attached Files

  6. #6
    Forum Expert
    Join Date
    01-03-2006
    Location
    Waikato, New Zealand
    MS-Off Ver
    2010 @ work & 2007 @ home
    Posts
    2,243

    Re: Dynamic range for pivot table

    For some reason I can't open the dummy file ("...wrong format or corrupt..."), can anyone else open the file in Webbug's previous post & suggest how the runtime error can be fixed?


    Webbug, I'm on Excel 2007 at the moment but can't open the xlsm version, would you be able to upload it as an "'97-2003 compatible .xls" file?

    Thanks
    Rob

  7. #7
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481

    Re: Dynamic range for pivot table

    This works for me in Macro2

    Please Login or Register  to view this content.
    Cheers
    Andy
    www.andypope.info

  8. #8
    Registered User
    Join Date
    04-01-2009
    Location
    new delhi
    MS-Off Ver
    Excel 2003
    Posts
    45

    Re: Dynamic range for pivot table

    Dear Andy and Rob,

    This worked perfectly.

    I will really appreciate if you could kindly address the following request.

    http://www.excelforum.com/excel-prog...ml#post2083801

    Webbug
    Last edited by webbug08; 04-30-2009 at 02:26 PM.

  9. #9
    Forum Expert
    Join Date
    01-03-2006
    Location
    Waikato, New Zealand
    MS-Off Ver
    2010 @ work & 2007 @ home
    Posts
    2,243

    Re: Dynamic range for pivot table

    Thanks Andy :-)

    Do you have any idea if there is somewhere in the VBE or Excel options that could allow the use of "rng" to work for me (without a conversion to a string) but not for Govind?
    (I had had a go at converting to a string based on viewing my recorded macro but I must have missed a ".parent" section.)

    Rob

  10. #10
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481

    Re: Dynamic range for pivot table

    For xl2003 this version of the code will work without converting rng to a string reference.

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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