Almost working using...

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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.
 
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
 
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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top