ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Pivot Table - Hiding Rows (https://www.excelbanter.com/excel-programming/291618-pivot-table-hiding-rows.html)

Richard[_20_]

Pivot Table - Hiding Rows
 
I have the following items:
1. A simplified database (DB) with 2 columns - column A:
Spare Parts ID (alphanumeric); column B: values. The DB
is the input to a Pivot Table (IDs to Row, values to
Data).

2. A macro that highlights all the items in the DB
(colorindex = 36) that have a specified ID. The
specified ID is obtained via an Inputbox.

3. A second macro hides all rows in the Pivot Table
except for a specified ID:

The second macro:

For Each p In ActiveSheet.PivotTables
("PivotTable1").PivotFields("SpareParts_ID").Pivot Items
p.Visible = (p.Name = myCell)
Next p

Where "myCell" is an ID of a spare part and is obtained
via another InputBox.

After highlighting the specified ID in the database
(first macro), how do I hide all rows in the Pivot Table
except for the IDs highlighted in the database? In short,
the variable "myCell" in the second macro needs to relate
to the highlighted ID (first macro).

TIA

Richard


Tom Ogilvy

Pivot Table - Hiding Rows
 
For each cell in Range("DB").Columns(1).cells
if cell.Interior.ColorIndex = 36 Then
myCell = cell.Value
exit for
end if
Next
For Each p In ActiveSheet.PivotTables
("PivotTable1").PivotFields("SpareParts_ID").Pivot Items
p.Visible = (p.Name = myCell)
Next p

--
Regards,
Tom Ogilvy


"Richard" wrote in message
...
I have the following items:
1. A simplified database (DB) with 2 columns - column A:
Spare Parts ID (alphanumeric); column B: values. The DB
is the input to a Pivot Table (IDs to Row, values to
Data).

2. A macro that highlights all the items in the DB
(colorindex = 36) that have a specified ID. The
specified ID is obtained via an Inputbox.

3. A second macro hides all rows in the Pivot Table
except for a specified ID:

The second macro:

For Each p In ActiveSheet.PivotTables
("PivotTable1").PivotFields("SpareParts_ID").Pivot Items
p.Visible = (p.Name = myCell)
Next p

Where "myCell" is an ID of a spare part and is obtained
via another InputBox.

After highlighting the specified ID in the database
(first macro), how do I hide all rows in the Pivot Table
except for the IDs highlighted in the database? In short,
the variable "myCell" in the second macro needs to relate
to the highlighted ID (first macro).

TIA

Richard




Richard[_20_]

Pivot Table - Hiding Rows
 
Tom,

Thank you very much.

Regards,

Richard

-----Original Message-----
For each cell in Range("DB").Columns(1).cells
if cell.Interior.ColorIndex = 36 Then
myCell = cell.Value
exit for
end if
Next
For Each p In ActiveSheet.PivotTables
("PivotTable1").PivotFields("SpareParts_ID").Pivo tItems
p.Visible = (p.Name = myCell)
Next p

--
Regards,
Tom Ogilvy


"Richard" wrote in

message
...
I have the following items:
1. A simplified database (DB) with 2 columns - column

A:
Spare Parts ID (alphanumeric); column B: values. The DB
is the input to a Pivot Table (IDs to Row, values to
Data).

2. A macro that highlights all the items in the DB
(colorindex = 36) that have a specified ID. The
specified ID is obtained via an Inputbox.

3. A second macro hides all rows in the Pivot Table
except for a specified ID:

The second macro:

For Each p In ActiveSheet.PivotTables
("PivotTable1").PivotFields("SpareParts_ID").Pivot Items
p.Visible = (p.Name = myCell)
Next p

Where "myCell" is an ID of a spare part and is obtained
via another InputBox.

After highlighting the specified ID in the database
(first macro), how do I hide all rows in the Pivot

Table
except for the IDs highlighted in the database? In

short,
the variable "myCell" in the second macro needs to

relate
to the highlighted ID (first macro).

TIA

Richard



.



All times are GMT +1. The time now is 03:01 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com