haroblueman
New Member
- Joined
- Jun 13, 2016
- Messages
- 1
Hello. First time post, long time user of this sites great ideas.
Problem Set: I have (1) Work Sheet that has (4) columns, (140) Rows. Columns: Item 1, Item 2, Item 3, Item 4. > Created a Pivot Table in another Work Sheet that has these columns in a hierarchy in column A. I would like to (via VBA) link the [+]/[-] buttons in the Pivot Table (Column Name: Item 1, Item 2, Item3) to the Rows in the Work Sheet. Therefore I can hide and show data to the outside of the pivot table in columns B and on to the right. I have managed to get it to work hard coding the locations of each cell that has a [+]/[-] button available, but this isn't dynamic and if my users update the Items list and add another row it will throw off the exact cell reference in the VBA.
Work so Far:
Private Sub Worksheet_PivotTableUpdate(ByVal Target As PivotTable)
With Application
.EnableEvents = False
.ScreenUpdating = False
End With
Dim rCell As Range
Cells.EntireRow.Hidden = False
For Each rcell In Range("A7:A140")
If rCell.Select = True Then
rCell.EntireRow.Hidden = True
Else
rCell.EntireRow.Hidden = False
End If
Next rCell
Application.EnableEvents = True
End Sub
Problem Set: I have (1) Work Sheet that has (4) columns, (140) Rows. Columns: Item 1, Item 2, Item 3, Item 4. > Created a Pivot Table in another Work Sheet that has these columns in a hierarchy in column A. I would like to (via VBA) link the [+]/[-] buttons in the Pivot Table (Column Name: Item 1, Item 2, Item3) to the Rows in the Work Sheet. Therefore I can hide and show data to the outside of the pivot table in columns B and on to the right. I have managed to get it to work hard coding the locations of each cell that has a [+]/[-] button available, but this isn't dynamic and if my users update the Items list and add another row it will throw off the exact cell reference in the VBA.
Work so Far:
Private Sub Worksheet_PivotTableUpdate(ByVal Target As PivotTable)
With Application
.EnableEvents = False
.ScreenUpdating = False
End With
Dim rCell As Range
Cells.EntireRow.Hidden = False
For Each rcell In Range("A7:A140")
If rCell.Select = True Then
rCell.EntireRow.Hidden = True
Else
rCell.EntireRow.Hidden = False
End If
Next rCell
Application.EnableEvents = True
End Sub