+ Reply to Thread
Results 1 to 11 of 11

Pivot Table DataSource

  1. #1
    Registered User
    Join Date
    03-12-2008
    Posts
    11

    Pivot Table DataSource

    hola - having a nightmare with a pivottable in VBA. I cannot give it a dynamic datasource. Surely i must be coding this wrong.

    please take a look at the code

    it breaks on setting the range for PTRange with the error
    Run Time Error '1004'

    application-defined or object-defined error
    Please Login or Register  to view this content.
    cheers

  2. #2
    Registered User
    Join Date
    05-28-2008
    Posts
    13
    Hi

    Are you sure lastrow_rng and lastCol have some values like one below

    Please Login or Register  to view this content.
    Last edited by VBA Noob; 07-24-2008 at 08:44 AM.

  3. #3
    Registered User
    Join Date
    03-12-2008
    Posts
    11
    hi shasur-

    yes they are variables set dynamically above

    in this instance

    lastcol = AY
    lastRow_rng = 16899

  4. #4
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481
    lastcol needs to be numeric rather than the column letters.

    lastcol = 51 'AY
    Cheers
    Andy
    www.andypope.info

  5. #5
    Registered User
    Join Date
    03-12-2008
    Posts
    11
    hey andy, niceone...didnt think of that

    but still getting the same message

    lastcol_rng = Range("A1").End(xlToRight).Column

    so lastcol_rng = 51 as you said

    but still this irritating message grrr

    am i setting PTRange correctly?

    Please Login or Register  to view this content.

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

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    03-12-2008
    Posts
    11
    sorry my bad.

    still not working - same error message

    close to giving up and use messy record macro style

  8. #8
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481
    Currently you problem has nothing to do with the pivot cache or table code so this is simple an assigment of a range to a range object using parameters.

    Does the following error?

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    03-12-2008
    Posts
    11
    that returns

    A$$1:$AY$16384 (when applied to my range)

    now the same error is here:

    Please Login or Register  to view this content.

  10. #10
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481
    Where did the Create method come from?

    Try using
    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    03-12-2008
    Posts
    11
    it came from my retarded brain. ive been staring at this code too long

    cache now added. i've got another error with

    Please Login or Register  to view this content.
    but i shall sort that out

    thanks for the help andy

+ 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