Unable to refresh pivot table - Getting error - "This Command Needs at Least 2 rows of Source Data"

rockyseenu

New Member
Joined
Sep 19, 2011
Messages
1
Dear Friends,

This is my first post, so kindly excuse if i am not following the standard procedures correctly - My problem is with the refresh of a pivot table in my worksheet - i am using the below code to refresh all pivot tables in the workbook. But this is returning an error "This command needs at least two rows of source data.......". I am not able to refresh the data in the pivot tables manually either. Getting the same error. Appreciate any support with this. Many Thanks.

Code:

Dim pt As PivotTable
Dim wkb As Workbook
Dim wks As Worksheet

Set wkb = ActiveWorkbook
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
For Each wks In wkb.Worksheets

For Each pt In wks.PivotTables
Application.StatusBar = "Refreshing " & pt.Name & " From " & wks.Name
pt.RefreshTable

Next pt

Next wks
Application.Calculation = xlCalculationAutomatic
Application.StatusBar = False
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.

Forum statistics

Threads
1,224,524
Messages
6,179,308
Members
452,904
Latest member
CodeMasterX

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