![]() |
Almost working using...
Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As
Boolean) Dim Selected Set Selected = ActiveCell Sheets("Notes").Select Selection.AutoFilter Field:=1, Criteria1:=ActiveCell.Value, Operator:=xlAnd End Sub When I right click a cell, it filters using the value from the cell. Unfortunately, this only works "properly" for the first value in sheet1. For the other values it says they are filtered by, but no rows are returned and when I go back to sheet1 to select another value then click, it keeps the original filter. Thanks, Mark. |
Almost working using...
Hi Mark, This seems to work... Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean) Cancel = True Dim Selected Selected = ActiveCell.Value Sheets("Notes").Select Selection.AutoFilter Field:=1, Criteria1:=Selected, Operator:=xlAnd Ken Johnson |
Almost working using...
Is this what you want?
Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean) Dim Selected Set Selected = ActiveCell Sheets("Notes").Select Cells.AutoFilter Field:=Selected.Column, Criteria1:=ActiveCell.Value, Operator:=xlAnd End Sub -- HTH Bob Phillips (replace somewhere in email address with gmail if mailing direct) "Mark Stephenson" wrote in message ... Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean) Dim Selected Set Selected = ActiveCell Sheets("Notes").Select Selection.AutoFilter Field:=1, Criteria1:=ActiveCell.Value, Operator:=xlAnd End Sub When I right click a cell, it filters using the value from the cell. Unfortunately, this only works "properly" for the first value in sheet1. For the other values it says they are filtered by, but no rows are returned and when I go back to sheet1 to select another value then click, it keeps the original filter. Thanks, Mark. |
Almost working using...
Fantastic,
Works a treat Thanks for your help "Ken Johnson" wrote: Hi Mark, This seems to work... Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean) Cancel = True Dim Selected Selected = ActiveCell.Value Sheets("Notes").Select Selection.AutoFilter Field:=1, Criteria1:=Selected, Operator:=xlAnd Ken Johnson |
Almost working using...
Hi Mark,
You're welcome, thanks for the feedback. Ken Johnson |
All times are GMT +1. The time now is 01:30 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com