Temporisation d'un code

Bonsoir

le code suivant est executé par un double click , existe un moyen de temporiser ce dernier afin qu'il soit executé toute les 2mn

ce qui eviterait ce double clik ?

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Range("B21:C100").Select
Selection.Sort Key1:=Range("B21:C100"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Range("B21:C100").Select
end sub

Merci pour vos idées sur la question

Bonsoir rocket4,

Un code à tester :

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    Cancel = True
    t = TimeValue("00:00:10")    'le programme s'arrête dans 10 min
    fin = Time + t
    maintenant = Time + TimeValue("00:02:00")
    Do While Time < fin
        DoEvents
        If TimeValue(Time) = TimeValue(maintenant) Then
            Range("B21:C100").Select
            Selection.Sort Key1:=Range("B21:C100"), Order1:=xlAscending, Header:=xlGuess, _
                           OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
            Range("B21:C100").Select
            maintenant = Time + TimeValue("00:02:00")
        End If
    Loop
End Sub

Bonjour,

Une autre manière de faire la même chose.

2092mn-v1.zip (15.57 Ko)

Merci à tout les deux ,!!!! merci pour avoir donné de votre temps !!!!

Cordialement , Rocket :

Rechercher des sujets similaires à "temporisation code"