user7984942
user7984942

Reputation:

Macro filtering pivot table through a cell in Excel

I would like to build a VBA macro to have a cell, where I can type a string, start the macro which filters a pivot table from another sheet called PIVOT.

I do have a solution via Inputbox (see below), but I prefer using a cell.

Sub Macro1()

Dim IdentificationNo As String
IdentificationNo = InputBox(Prompt:="Identification", Title:="ENTER IDENTIFICATION NUMBER")
    Sheets("PIVOT").PivotTables("PivotTable1") _
        .PivotFields("Identification #").CurrentPage = IdentificationNo

End Sub

Upvotes: 0

Views: 378

Answers (1)

YowE3K
YowE3K

Reputation: 23974

Change

IdentificationNo = InputBox(Prompt:="Identification", Title:="ENTER IDENTIFICATION NUMBER")

to

IdentificationNo = Worksheets("Sheet1").Range("A1").Value

That will use the value from Sheet1!A1 as the input, so change "Sheet1" and "A1" as needed.

Upvotes: 1

Related Questions