• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Keep Pivot Table format as it is after Refrfeshing

Surekha

Member
Hi All,
I am refreshing my pivot table range at run time. But after refreshing the pivot the format of it will changed automatically.
Can someone help me to sort it out as I want to keep same format which is ther in file.
Also I dont want to assign full range to pivot.
Thanks for advance
 

Attachments

Please try following macro to refresh the pivot table. Also please find the attached file with the macro and updated "Refresh" button.

Code:
Sub RefreshPT()
    Dim lastRow, lastColmn As Long
    'Dim newRange As Range
    lastRow = Worksheets("Sheet1").UsedRange.Rows.Count
    lastColmn = Worksheets("Sheet1").UsedRange.Columns.Count
    endr = Sheets("Sheet1").Cells(lastRow, lastColmn).Address
    newRange = "Sheet1!A1:" & Sheets("Sheet1").Cells(lastRow, lastColmn).Address
    Sheets("Sales Summary").PivotTables("PT1").ChangePivotCache ThisWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:=newRange)
    Sheets("Sales Summary").PivotTables("PT1").RefreshTable
End Sub
 

Attachments

Hi All,

I just wanted to share Camera tool function with you all which is there in excel and it is very useful while creating Dashboards.

Thanks!
 

Attachments

Back
Top