+ Reply to Thread
Results 1 to 1 of 1

formulas based on pivot table cells not dynamic && GetPivotData form not flexible

  1. #1
    Registered User
    Join Date
    12-08-2017
    Location
    Minneapolis, MN
    MS-Off Ver
    Standard 2013
    Posts
    83

    formulas based on pivot table cells not dynamic && GetPivotData form not flexible

    I'm kind of a novice at pivot tables. I'm making this massive macro (to me anyway) that takes a "Practice Management" employee client service report, formats it and spits out a pivot table on a new worksheet. It's been going really well actually. Functions are calling other functions and it's beautiful.

    On the pivot table worksheet, it looks pretty good too. The manager wants a range of cells to the right of the table to be prepopulated & preformatted, shaded and to include formulas referencing some cells in the table and other cells the manager manually enters for prior year to current year comparisons. I can do it all until I get to the formula that has to reference a cell in the pivot table

    I'm kind of new to how pivot tables work. Why can't it be simple enough that I can just make a formula as you normally would (a2-a1)? Instead you choose a cell in the table and it spits out this:

    Please Login or Register  to view this content.
    When I ran that, in a loop, I thought this was good but turns out it is not dynamic. It doesn't change the value based on the row. All values were the same as row 1 of the table.


    I understand pasting the PT as a value is an option. I'd consider that if I had to bu I don't want to.

    What is with this GETPIVOTDATA function? Why can't it just refer to cell K7?

    Then I thought I'd copy the value of the first cell in each row (where the table is rooted) and insert that in the right spot of the formula as an argument in that big formula. I thought I knew how to do this king of thing. I think pivot tables throw everything off. It didn't work for whatever reason, so instead I just declared a few variables

    dim cellcontents (= the value in A1, so in our first case it would be "401 Other General Procedures" but in our second case, not shown here, it should say "401 Planning" and so on.
    dim stringtopaste


    I had these two lines of code:

    Please Login or Register  to view this content.
    I played around with quotes in case it was something like that. Basically it's not dropping the value of stringtopaste into the formula. I can see in my locals window it is what I want it to be, or close. It either gives me an error [Application defined or object defined error] or with quotes just pastes the name of the variable, not it's contents "stringtopaste", so that's useless.

    I don't even know if this is the best approach to making the pivot table references dynamic. All open to ideas, whatever works, whatever is the simplest.

    Pivot tables are powerful and I like them, but why are they so funky with formulas and working with VBA?

    ps you can see my entire code on
    https://github.com/ryanpotato/VBA-fo...ob/master/main
    it might not be absolutely up to date wrt the questions in this post, not sure when last committed, but you get the gist.
    Last edited by foxtrotter; 10-09-2019 at 05:09 PM.

+ 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] Sum formulas based on dates and items in single month - dynamic for table
    By mpost54 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 12-29-2018, 03:05 AM
  2. [SOLVED] Pivot Table based on Dynamic Range
    By wharmon3 in forum Excel General
    Replies: 7
    Last Post: 11-02-2018, 09:01 AM
  3. [SOLVED] Pivot Table #REF! when I based the GETPIVOTDATA on cells containing formulas
    By seanpcorbett1 in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 09-20-2016, 01:35 AM
  4. Adding a series of cells in a Pivot Table using GetPivotData function
    By Pratik Bhatia in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 10-15-2013, 10:00 AM
  5. Replies: 2
    Last Post: 05-08-2013, 04:56 PM
  6. Pivot Table based on dynamic table
    By CydMM in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-28-2010, 06:59 AM
  7. Dynamic Pivot Chart based on Pivot Table.
    By excelkeechak in forum Excel General
    Replies: 3
    Last Post: 12-01-2009, 09:23 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