Macro that choose a pivotfieldvalue from cell value and updates pivot

blaksnm

Well-known Member
Joined
Dec 15, 2009
Messages
554
Office Version
  1. 365
Platform
  1. Windows
Hey guys
I have a report-workbook with periodical (monthly) updates/revisions.
The datas is placed as in a "database" (Mainbase) which the pivot-tables (used in my report-sheet) is based on.
By some inputsheets my macro generate this database that expands when a new revision is approved.

My macro designs a report that contains of a number of different pivot-tables - all with use of different dispositions of the available data in Mainbase.

After accumulating the mainbase with all revisions I would like to instruct my macro to show the pivot-tables with just the specified revision (stated in range A1.value)

Will anyone kindly - as many times before :) - guide me on this one?
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Thanks for your interest Andrew
My recorded macro:

Sub Makro1()
With ActiveSheet.PivotTables("Pivottabell1").PivotFields("Rev Current")
.PivotItems("Rev 00").Visible = False
.PivotItems("Rev 01").Visible = False
.PivotItems("Rev 02").Visible = True
End With
End Sub

The expession RevXX is a range ("A1").value in fact
I want only this pivotfieldvalue to show in the pivottable -all other fieldvalues = visible= false
 
Upvote 0
Try:

Code:
Sub Test()
    Dim PI As PivotItem
    With ActiveSheet.PivotTables("Pivottabell1").PivotFields("Rev Current")
        .PivotItems(Range("A1").Value).Visible = True
        For Each PI In .PivotItems
            PI.Visible = PI.Name = Range("A1").Value
        Next PI
    End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,524
Messages
6,179,308
Members
452,904
Latest member
CodeMasterX

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top