SetFocus on a pivot table

timtimba

New Member
Joined
Apr 8, 2013
Messages
28
Hi,

I have a drop down list (a simple list with unique values).

All I want to do is when a user selects this list, the focus moves to the cell within the pivot table where the value is matched.

Is this possible?

Thanks
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Is this a row/column/page/data field, or could it be any of those?
 
Upvote 0
Its row .....

at the moment I am just using conditinal formatting to hoghlight the column based on the drop down list above .... but I want to move to the cell within the sheet when the drop down is selected.

E.G.

list contains apple, pear, tomato

when apple is selected, the corresponding apple field within the pivot list is highlighted. however I want to move the focus to the apple cell too.
 
Upvote 0
You should be able to use code like this:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
   Dim pt As PivotTable
   Dim MonitorCell As Range
   ' this is cell containing the list
   Set MonitorCell = Range("Q5")
   
   If Not Intersect(Target, MonitorCell) Is Nothing Then
      Set pt = ActiveSheet.PivotTables(1)
      pt.PivotSelect MonitorCell.Value, xlLabelOnly
   End If


End Sub
adjusting the ranges to suit your workbook.
 
Last edited:
Upvote 0
Right-click the worksheet tab where the dropdown and pivot are, choose View Code, then paste that in.
 
Upvote 0
gets the following error:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim pt As PivotTable
Dim MonitorCell As Range
' this is cell containing the list
Set MonitorCell = Range("A1")

If Not Intersect(Target, MonitorCell) Is Nothing Then
Set pt = ActiveSheet.PivotTables(1)
pt.PivotSelect MonitorCell.Value, xlLabelOnly
End If

End Sub
 
Upvote 0
Can you put a sample file somewhere? That code worked in my (admittedly quick) tests using a row field.
 
Upvote 0
Based on the picture you messaged me, A1 bears no relation to any value you are searching for?
 
Upvote 0

Forum statistics

Threads
1,203,136
Messages
6,053,699
Members
444,681
Latest member
Nadzri Hassan

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