'A mettre dans Thisworkbook
Private Sub Workbook_SheetBeforeDoubleClick(ByVal Sh As Object, ByVal Target As Range, Cancel As Boolean)
'On Error Resume Next
Cancel = True
'ActiveSheet.ShowAllData
On Error GoTo suite
nlact = ActiveCell.Rows.Row
ncact = ActiveCell.Columns.Column
ordre = Mid$(ActiveWorkbook.Names("ordretexte").Value, 2, 1)
Cells(nlact, ncact).Select
Selection.CurrentRegion.Select
ActiveWorkbook.Names.Add Name:="Fortri", RefersToR1C1:=Selection
If ordre = "1" Then Selection.Sort Key1:=Cells(nlact, ncact).Value, Order1:=xlDescending, Header:=xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
If ordre = "2" Then Selection.Sort Key1:=Cells(nlact, ncact).Value, Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Cells(nlact, ncact).Select
ordre = ordre + 1: If ordre = 3 Then ordre = 1
ActiveWorkbook.Names.Add Name:="ordretexte", RefersToR1C1:=ordre
End
suite:
ActiveWorkbook.Names.Add Name:="ordretexte", RefersToR1C1:=1
End Sub
Private Sub Workbook_SheetBeforeRightClick(ByVal Sh As Object, ByVal Target As Range, Cancel As Boolean)
On Error Resume Next
Cancel = True
'Stop
'ActiveSheet.ShowAllData
derl = [A65536].End(xlUp).Row: derc = [IV1].End(xlToLeft).Column
If ActiveCell.Row <> 1 Then Exit Sub
ColN = ActiveCell.Column
Application.ScreenUpdating = False
NAT = InputBox("Filtre contient?")
Selection.AutoFilter
ActiveSheet.Range(Cells(1, 1), Cells(derl, derc)).AutoFilter Field:=ColN, Criteria1:="=*" & NAT & "*" _
, Operator:=xlAnd
End Sub
'------------------------------------------------------------------------------------------
'A mettre dans un module normal
'Sub ote_filtre()
'Cancel = True
'ActiveSheet.ShowAllData
'End Sub