Results 1 to 5 of 5

Need Help Updating Pivot Table Source Data

Threaded View

  1. #1
    Registered User
    Join Date
    02-21-2019
    Location
    STL
    MS-Off Ver
    2013
    Posts
    10

    Need Help Updating Pivot Table Source Data

    So I'm brand new to VBA and having a hard time figuring out how to use a macro to update the source data on an existing pivot table.
    I have data in columns A:AX, AX contains dates and I have the macro sort them leaving the blanks on bottom. I want the macro to select the source data from A1 to the last row containing data in AX. I want to do this without deleting the rows containing blank AX cells.

    This is what I have so far. No clue if I'm close or completely wrong.

    Dim DSheet As Worksheet
        Dim PRange As Range
        Dim LastRow As Long
        Dim LastCol As Long
        Set DSheet = Worksheets("Tool NCRs")
        LastRow = DSheet.Cells(Rows.Count, "AX").End(xlUp).Row
        LastCol = DSheet.Cells(1, Columns.Count).End(xlToLeft).Column
        Set PRange = DSheet.Cells(1, 1).Resize(LastRow, LastCol)
        ActiveSheet.PivotTables("PivotTable6").ChangePivotCache ActiveWorkbook. _
            PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
            "PRange", _
            Version:=xlPivotTableVersion15)
        ActiveSheet.PivotTables("PivotTable6").PivotCache.Refresh
    EDIT* This pivot groups by dates and it won't let me do that if there are blanks. If I use a table it still pulls in blanks and ungroups my dates
    Last edited by walt737; 02-22-2019 at 08:36 AM. Reason: Additional info

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Updating the source data of a Pivot Table
    By AhmedAbdelhai in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 05-28-2018, 05:13 AM
  2. Replies: 0
    Last Post: 01-06-2016, 07:00 AM
  3. Updating Pivot Source Data Automatically
    By swade730 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-19-2015, 02:49 PM
  4. [SOLVED] Updating data source and refreshing all pivot tables through VBA.
    By Folshot in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 11-26-2013, 10:01 AM
  5. [SOLVED] Problem updating source for pivot table
    By flyboy54 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-04-2013, 12:35 PM
  6. updating pivot tables using dynamic data source
    By dab4211 in forum Excel General
    Replies: 3
    Last Post: 07-24-2006, 04:45 PM
  7. [SOLVED] Updating source data while in Pivot Table
    By Carim in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-27-2005, 10:06 AM

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