+ Reply to Thread
Results 1 to 4 of 4

refresh pivot data with visible data

  1. #1
    Registered User
    Join Date
    01-04-2013
    Location
    india
    MS-Off Ver
    Excel 2007
    Posts
    8

    refresh pivot data with visible data

    Hi I am new to excel forum. I have recorded a macro. in between there is a pivot table which needs to be daily refreshed with all visible cell. The number of rows and colums will change.

    is there any way to refresh the pivot with all visible cells

    ActiveSheet.PivotTables("PivotTable4").ChangePivotCache ActiveWorkbook. _
    PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
    "C:\Users\kkk\Desktop\[Jan5.xlsx]Sheet1!R1C1:R179C34" _
    , Version:=xlPivotTableVersion12)

    as in the code the source is from R1C1:R179C34. is there any way to select only visible cells.

  2. #2
    Registered User
    Join Date
    01-06-2013
    Location
    chennai
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: refresh pivot data with visible data

    Hi,

    run the below macro

    instead of dashboard you enter the sheetname of pivot tsble sheet and above code in sheet1 you have the data right.suppose you change the sheet name of data sheet , change the sheet name in codeing also.

    Sub UpdatePivot()
    Application.ScreenUpdating = False

    Sheets("sheet1").Select
    Range("A1").Select
    Range(Selection, Selection.End(xlToRight)).Select
    Range(Selection, Selection.End(xlDown)).Select
    With ActiveWorkbook.Names("PivotData")
    .Name = "PivotData"
    .RefersToR1C1 = Selection
    .Comment = ""
    End With
    ActiveWorkbook.RefreshAll
    Worksheets("Dashboard").Select
    Application.ScreenUpdating = True
    End Sub

    Vijay

  3. #3
    Registered User
    Join Date
    01-06-2013
    Location
    chennai
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: refresh pivot data with visible data

    Hi,

    Here is the macro for refresh the data
    Note: rename the sheetname in first line and last line (for "data" you can put your data sheet name and for "dashboard" you put your pivot sheet name


    Sub UpdatePivot()
    Application.ScreenUpdating = False

    Sheets("Data").Select
    Range("A1").Select
    Range(Selection, Selection.End(xlToRight)).Select
    Range(Selection, Selection.End(xlDown)).Select
    With ActiveWorkbook.Names("PivotData")
    .Name = "PivotData"
    .RefersToR1C1 = Selection
    .Comment = ""
    End With
    ActiveWorkbook.RefreshAll
    Worksheets("Dashboard").Select
    Application.ScreenUpdating = True
    End Sub

  4. #4
    Registered User
    Join Date
    01-04-2013
    Location
    india
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: refresh pivot data with visible data

    thanks a lot

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1