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.
Et ça ne me le fait pas avec le simple clique.
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.
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.
Et ça ne me le fait pas avec le simple clique.
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: