run-time error 1004 Unable to get the PivotFields property of the PivotTable Class

cwelt21

New Member
Joined
Oct 30, 2017
Messages
6
I'm running into a strange problem, for many years I have used these excel macros and all of a sudden I started to receive errors that only appear on one computer. This macro and pivot issue doesn't exist on any other computer I have tried. So excel was uninstalled and a fresh clean updated copy has been installed and the issue still exists.

run-time error 1004 Unable to get the PivotFields property of the PivotTable Class

VBA notes the error being located with the code of:

ActiveSheet.PivotTables(1) .PivotFields("count of quantity") .Function = xlSum

Any ideas of why I would have this issue on one computer only?.. Also please note this worked fine for many years on this same computer and then one day just developed this problem out of nowhere.
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Welcome to the forum.

Are you sure the right sheet is active when the code is running? Does the same code work on the same workbook on other computers?
 
Upvote 0
all sheet selections are done as part of a macro string, this same file was saved on multiple computers and ran fine on all of them with no errors at all. This problem exists on this one computer only, using the same exact file. I did not write the code myself but I can tell you that this has worked without fail for many years until about 3 days ago. No changes have been made at all, the same file was sent to another computer and worked fine, then it was sent back to the computer that received errors and the errors were present again and again. I have tested this about 10 times back and forth, with the same results every time, errors on only one single computer.
 
Upvote 0
I can't see why that would error. Does this work on that computer:

Code:
ActiveSheet.PivotTables(1).PivotFields("quantity").Function = xlSum
 
Upvote 0
removing the "count of" did not help, even on a computer that was working, it produces another 1004 runtime error

Unable to set the Function property of the PivotField class
 
Upvote 0
You’ll probably need to post some more of the code then. I suspect that line may be unnecessary anyway with a small code change.
 
Upvote 0
I thought you said all sheet selections were done as part of the macro?
 
Upvote 0
The way this was written is we have one macro to run that then runs a series of macros in a particular order. So there is one macro that runs a few sub macros. The macro that errors each time only contains the code I posted above. As a test I removed the macro that contained the code listed above and no other errors appeared. So any errors that have happened are linked directly to that one line of code and is only a issue on one single computer.
 
Upvote 0
I'm afraid that I can't offer further suggestions without all the rest of the code. I can't really fathom why anyone would put that one line of code into a separate routine.
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

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