[Résolu] Double Click pour lancer un userform

Guillaume33

XLDnaute Nouveau
Bonjour à tous,

J'ai créé un userform et j'arrive à le lancer en cliquant simplement sur les cellules concernées. J'arrive aussi à lancer cet userform en double cliquant sur ces cellules mais ça ne fait pas pareil...

Par moment, le premier choix que je dois choisir et qui doit apparaître dans la première liste est déjà sélectionné. Des fois, ça marche correctement mais pas tout le temps.

Image 2 - Double click.jpg

Et ça ne me le fait pas avec le simple clique.

Image 1 - Simple click.jpg


Avec le simple clique j'ai ce code qui marche bien :

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Range("B14:B33"), Target) Is Nothing And Target.Count = 1 Then
choix.Left = Target.Left
choix.Top = Target.Top + 180 - Cells(ActiveWindow.ScrollRow, 1).Top
choix.Show
End If
If Not Intersect(Range("B39:B58"), Target) Is Nothing And Target.Count = 1 Then
choix.Left = Target.Left
choix.Top = Target.Top + 180 - Cells(ActiveWindow.ScrollRow, 1).Top
choix.Show
End If
If Not Intersect(Range("B64:B83"), Target) Is Nothing And Target.Count = 1 Then
choix.Left = Target.Left
choix.Top = Target.Top + 180 - Cells(ActiveWindow.ScrollRow, 1).Top
choix.Show
End If
If Not Intersect(Range("B87:B106"), Target) Is Nothing And Target.Count = 1 Then
choix.Left = Target.Left
choix.Top = Target.Top + 180 - Cells(ActiveWindow.ScrollRow, 1).Top
choix.Show
End If
If Not Intersect(Range("B110:B129"), Target) Is Nothing And Target.Count = 1 Then
choix.Left = Target.Left
choix.Top = Target.Top + 180 - Cells(ActiveWindow.ScrollRow, 1).Top
choix.Show
End If
End Sub


Et pour le double click, j'ai mis ça qui marche mais avec le soucis que j'ai évoqué plus haut :

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Cancel = True
If Not Intersect(Range("B14:B33"), Target) Is Nothing And Target.Count = 1 Then
choix.Left = Target.Left
choix.Top = Target.Top + 180 - Cells(ActiveWindow.ScrollRow, 1).Top
choix.Show
End If
If Not Intersect(Range("B39:B58"), Target) Is Nothing And Target.Count = 1 Then
choix.Left = Target.Left
choix.Top = Target.Top + 180 - Cells(ActiveWindow.ScrollRow, 1).Top
choix.Show
End If
If Not Intersect(Range("B64:B83"), Target) Is Nothing And Target.Count = 1 Then
choix.Left = Target.Left
choix.Top = Target.Top + 180 - Cells(ActiveWindow.ScrollRow, 1).Top
choix.Show
End If
If Not Intersect(Range("B87:B106"), Target) Is Nothing And Target.Count = 1 Then
choix.Left = Target.Left
choix.Top = Target.Top + 180 - Cells(ActiveWindow.ScrollRow, 1).Top
choix.Show
End If
If Not Intersect(Range("B110:B129"), Target) Is Nothing And Target.Count = 1 Then
choix.Left = Target.Left
choix.Top = Target.Top + 180 - Cells(ActiveWindow.ScrollRow, 1).Top
choix.Show
End If
End Sub

Est-ce qu'il y a des choses qui ne vont pas dans les codes ou c'est juste un "bug" qui ne peut pas être résolu ?

Merci d'avance pour vos réponses et je suis prêt à répondre à vos questions pour plus d'informations.

Guillaume

PS : Je ne peux pas joindre mon fichier car c'est un fichier d'une entreprise et je n'ai pas le droit de le partager.
 
Dernière édition:

Guillaume33

XLDnaute Nouveau
Re : Double Click pour lancer un userform

J'ai trouvé tout seul !

Merci quand même si certains ont cherché ! En fait, comme l'userform apparaît au niveau du pointeur, en double cliquant, je sélectionne aussi le mot "Equipe" de la première liste... J'ai juste à relever un peu l'userform.

Désolé de vous avoir dérangé !
 

Statistiques des forums

Discussions
312 508
Messages
2 089 134
Membres
104 042
dernier inscrit
tropsy89