+ Reply to Thread
Results 1 to 4 of 4

Double-click Pivot Table Total

Hybrid View

  1. #1
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,970

    Double-click Pivot Table Total

    Sorry to bother you with this, but I'm brain dead today, and so I'm stumped. I've got a user selecting (via macro) various options to repopulate a pivot table. I'm interested in getting the data behind the pivot table (the data source is remote, and I don't have access to it). Once the selections are made, I want to (via VBA) double-click on the true Grand Total cell (at the lower right corner of the Pivot Table) to populate a sheet with the source data. How do I find that Grand Total cell programattically?

    Thanks in advance.
    Last edited by jomili; 08-26-2010 at 04:51 PM.

  2. #2
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,970

    Re: Finding specific cell

    Still needing help with finding the lower right corner of a pivot table via VBA.

  3. #3
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,970

    Re: Finding specific cell

    I'm partially there; I found and adapted this code from http://www.ozgrid.com/VBA/ExcelRanges.htm, and it gets me 3/4 of the way there:

    Sub FindLastCell()
    Dim LastColumn As Integer
    Dim LastRow As Long
    Dim LastCell As Range
    
    
        If WorksheetFunction.CountA(Cells) > 0 Then
    
            'Search for any entry, by searching backwards by Rows.
    
            LastRow = Cells.Find(What:="*", After:=[A1], _
                        SearchOrder:=xlByRows, _
                        SearchDirection:=xlPrevious).Row
    
            'Search for any entry, by searching backwards by Columns.
    
                    LastColumn = Cells.Find(What:="*", After:=[A1], _
                        SearchOrder:=xlByColumns, _
                        SearchDirection:=xlPrevious).Column
    
            MsgBox Cells(LastRow, LastColumn).Offset(0, -2).Address
           
        End If
        
    End Sub
    The MsgBox displays the cell I need to doubleclick, but I can't figure out how to doubleclick it. Here's my latest attempt, which results in a "Run-Time error 424: Object Required". What am I doing wrong?
    Sub FindLastCell()
    Dim LastColumn As Integer
    Dim LastRow As Long
    Dim LastCell As Range
    
    
        If WorksheetFunction.CountA(Cells) > 0 Then
    
            'Search for any entry, by searching backwards by Rows.
    
            LastRow = Cells.Find(What:="*", After:=[A1], _
                        SearchOrder:=xlByRows, _
                        SearchDirection:=xlPrevious).Row
    
            'Search for any entry, by searching backwards by Columns.
    
                    LastColumn = Cells.Find(What:="*", After:=[A1], _
                        SearchOrder:=xlByColumns, _
                        SearchDirection:=xlPrevious).Column
    
            Cells(LastRow, LastColumn).Offset(0, -2).Address.DoubleClick
           
        End If
        
    End Sub
    Last edited by jomili; 08-16-2010 at 10:42 AM.

  4. #4
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,970

    Re: Finding specific cell

    Okay, I found it:
    'Find and doubleclick the Grand Total on the Pivot Table
    Cells.Find(What:="*", After:=[A1], SearchDirection:=xlPrevious).Select
    Application.DoubleClick

+ 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