×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Microsoft: Office FAQ

PivotTable Tips

Viewing the Specific Source Data Rows for a PivotTable Summary Value by SkipVought
Posted: 23 Aug 12 (Edited 24 Aug 12)

There is a handy way to view the specific source data rows that correspond to the PivotTable summary value in a PivotTable.

You simply DOUBLE-CLICK any summary value, and a new sheet is inserted into your workbook with the specific source data rows that correspond to the PivotTable summary value the you DOUBLE-CLICKED. Its that simple!

If you do that a few times, you can get tired of having to DELETE these newly inserted sheets.

So here's how to 'fix' that problem, so that when you select off that newly inserted sheet to another sheet, it will automatically be deleted!

CAVEAT: Every sheet in your workbook that you want to keep, must have a Sheet Name that does not begin with Sheet
!!!

Here are the steps to getting there...

1. alt+F11 toggles between the sheet and the VB Editor, where macros are stored.

2. In the VB Editor, ctr+R activates the Project Explorer

3. In the Project Explorer, Right-Click the ThisWorkbook Microsoft Excel Object and select View Code.

4. Paste this code in that code window

CODE

Option Explicit

Private Sub Workbook_SheetDeactivate(ByVal Sh As Object)
    Application.DisplayAlerts = False
    If Left(Sh.Name, 5) = "Sheet" Then Sh.Delete
    Application.DisplayAlerts = False
End Sub 
5. SAVE the workbook as a macro-enabled workbook if you have Excel 2007+


If you want to be able to keep the Sheet to return to it without changing the Sheet Name, kind of a temporary thing, then here's a method for that.

Procedurally, make any selection in the sheet other than selecting all the data. This modified code will allow you to keep that un-renamed sheet. When you want it deleted, use the Select Current Region or ctr+A icon to select all the data.

CODE

Option Explicit
Public LastSelection As String

Private Sub Workbook_SheetDeactivate(ByVal Sh As Object)
    Application.DisplayAlerts = False
    If Left(Sh.Name, 5) = "Sheet" Then
        If LastSelection = Sh.[A1].CurrentRegion.Address Then Sh.Delete
        LastSelection = ""
    End If
    Application.DisplayAlerts = False
End Sub

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
    LastSelection = Target.Address
End Sub 

Back to Microsoft: Office FAQ Index
Back to Microsoft: Office Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close