• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Need Macro to filter pivot and provide data based on value

Aswinraj

Member
Hello Can anybody please help me on this...,

In Excel Sheet 1 contains more than 100 Account images and Sheet 2 contains some Raw data and Sheet 3 contains the Pivot table.

1. When User clicks any images, based on the image clicked it should filter the data in pivot table and show it to user.
2. Raw data will be keep on updating, so whenever the data has been added to rawdata sheet, the pivot should be updated automatically.

Example: I had attached an example sheet where i had added some images,
like image 1 (ABC) it should filter the data in pivot based on image name.
 

Attachments

  • SAMPLE.xlsx
    246.2 KB · Views: 4
1. Easiest method I can think of is to assign following code to each image by right clicking.
Code:
Sub ImgClick()
Dim sName As String
Dim pFilter As String

sName = ActiveSheet.Shapes(Application.Caller).Name
pFilter = ActiveWorkbook.Sheets("Dashboard").PivotTables("PivotTable1").PivotFields("Acct name").CurrentPage

If pFilter = sName Then
    Exit Sub
Else
    ActiveWorkbook.Sheets("Dashboard").PivotTables("PivotTable1").PivotFields("Acct name").CurrentPage = sName
End If
End Sub

2. Use named range to dynamically define Pivot Range.
upload_2016-1-13_19-6-18.png
upload_2016-1-13_19-7-1.png

See attached sample.

Edit: If you want to jump to Dashboard after clicking on the image add code below just before End If.
Code:
ActiveWorkbook.Sheets("Dashboard").Activate
 

Attachments

  • SAMPLE_ImgClick.xlsm
    252.5 KB · Views: 3
Last edited:
Back
Top