PivotTable Error

Ark68

Well-known Member
Joined
Mar 23, 2004
Messages
4,564
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I have made a Pivot Table on worksheet "CRITERIA"
As part of my code, I call to refresh that Pivot Table because it's contents are based on a dynamic dataset.
I am getting an error : "The PivotTable field name is not valid. ..." with line
Code:
 Sheets("CRITERIA").PivotTables("PivotTable1").PivotCache.Refresh

The dataset does have a valid column header for which the PivotTable uses to base it's count. Could it have something to do with the dataset having been "re-drawn" in a previous sub (importing the data from an external sopurce)?

How can I eliminate this error and have my PivotTable update it's values?

Jenn
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Found the error. One of the first cells of the range of columns I was using was empty. You're not supposed to have a blank first row cell apparently.
 
Upvote 0
OK ... new problem.
Why does my PivotTable contents disappear after I run my subrountine that imports data to be analysed by this PivotTable?

I have my PivotTable initially set up manually, and though that a simple refresh command would be all that was needed to compensate for the new data input.

Jenn
 
Upvote 0
when you import the data, is it on a sheet with the same name that the old data was on ?
are the number and name of columns the same ?
 
Upvote 0
Thank you James for your reply ....

The worksheet name and column headings remain unchanged. During the import of new data. Part of the import process involves deleting the header row and replacing it in case this may be the culprit.

When I go back to the PivotTable and try to use the Wizard, my original data range has changed from the original column (of a one column data reference) and thus I am unable to make the same field query. (ie the query is supposed to be based on column D "Type", but after I run my sub, it is trying to use column F "Function", which is not what I want)

Jenn
 
Last edited:
Upvote 0
OK, thanks Greg.
I suppose I'll have to revist my sub importing the data as to not delete the header row in the process.
 
Upvote 0

Forum statistics

Threads
1,214,576
Messages
6,120,350
Members
448,956
Latest member
Adamsxl

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