Microsoft 365 Imbrication de deux formule Worksheet_BeforeDoubleClick

Nathan027

XLDnaute Junior
Bonjour, je sollicite votre aide sur un sujet qui me bloque.
Je voudrais mettre deux codes dans la même feuille, mais si je les mets l'une après l'autre ca me créé un conflit
Chaque code fonctionne indépendamment.

Premier code (double clic - affichant un "x" dans la cellule sélectionnée)

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
temp = Array("X", "")
If Not Application.Intersect(Target, Range("B13:d1000,AF13:BM1000")) Is Nothing Then
With Target
p = Application.Match(Target, temp, 0)
If Not IsError(p) Then
If p = UBound(temp) + 1 Then p = 0
Else
p = 0
End If
Target = temp(p)
Cancel = True
End With
End If
End Sub


Second code pour copier dans H9 le contenu de la cellule sélectionnée de H15:H2000

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Application.Intersect(Target, Range("H15:H2000")) Is Nothing Then Exit Sub
Sheets("Planning").Range("H9").Value = Target.Value
Cancel = True
End Sub


J'espère que vous pourrez m'aider :)

Merci d'avance
 

Nathan027

XLDnaute Junior
Voici la solution qu'on m'a apporté et elle fonctionne :)

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
temp = Array("X", "")
If Not Application.Intersect(Target, Range("B13:D1000,AF13:BM1000")) Is Nothing Then
With Target
p = Application.Match(Target, temp, 0)
If Not IsError(p) Then
If p = UBound(temp) + 1 Then p = 0
Else
p = 0
End If
Target = temp(p)
Cancel = True
End With
End If '(Je l'ai retiré)
If Not Application.Intersect(Target, Range("H15:H2000")) Is Nothing Then
Sheets("Planning").Range("h9").Value = Target.Value
Cancel = True
End If
End Sub
 

Discussions similaires

Réponses
2
Affichages
138

Statistiques des forums

Discussions
312 206
Messages
2 086 226
Membres
103 159
dernier inscrit
FBallea