GETPIVOTDATA in Macro

pbapro2b

New Member
Joined
May 28, 2024
Messages
2
Office Version
  1. 2019
Platform
  1. Windows
I am newer to Macros, but I need help with this one. I know I cannot use =GETPIVOTDATA(blah.blahblah) as a formula in a macro. I have been searching this site and google for an example of what I am trying to accomplish.

Here is my situation. I need to report on service ticket SLA's on a weekly basis. My predecessor created a calculator sheet so I just need to copy and paste my ticket data into the sheet, refresh the pivot tables and it gives me the needed percentages of SLA's met. The calculator sheet is clunky and requires formula edits based on number of tickets each week, so I built a macro to encompass all the needs. I have everything working except for his GETPIVOTDADA formula. Here is the formula I am trying to properly write into a Macro:

=GETPIVOTDATA("Due Date SLA",$A$3,"Due Date SLA","Met")/GETPIVOTDATA("Due Date SLA",$A$3)

Here is a snippet of the pivot table in question. Range A3:B6
Closed Tickets
Row LabelsCount of Due Date SLA
Met
42​
(blank)
Grand Total
42​


When I run the formula on this particular week, I get 100% (Which is correct). Can I get some advice to get me in the right direction? I've tried Double Quotes, and I have tried Carriage Returns, but I cannot seem to get it to function properly.
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Assuming you are putting the formula in the active cell, how about:

VBA Code:
ActiveCell.FormulaR1C1 = "=GETPIVOTDATA(""Due Date SLA"",R3C1,""Due Date SLA"",""Met"")/GETPIVOTDATA(""Due Date SLA"",R3C1)"

If this doesn't work, I would copy that exact formula you have, record a macro, and paste that formula and click Stop Recording. And then the Macro should show the R1C1 way of getting the function.

Turn on the Developer tab if you don't have it on already so you can record a macro and stop recording it.
 
Upvote 0
Solution

Forum statistics

Threads
1,223,883
Messages
6,175,167
Members
452,615
Latest member
bogeys2birdies

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top