XL 2019 double clic sur une colonne

farid

XLDnaute Occasionnel
Bonsoir,
j'ai cette macro qui fonctionne très bien , mais fonctionne sur n'importa quel cellule alors que je souhaite que cela fonctionne uniquement sur la colonne A a partir de A2.
merci pour votre retour
Farid

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)

Dim rep$, nom$, C As Range
Cancel = True
rep = ActiveWorkbook.Path & "\SAUVEGARDE-OT\2022\"
nom = Target.Value
Call testouverture
If Not FichierOuvert(nom & ".xlsm") = True Then
Workbooks.Open rep & nom & ".xlsm"
Call testouverture
End If
End Sub
 
Solution
Bonsoir Farid,
Il faut limiter la portée de la macro :
VB:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    If Not Application.Intersect(Target, Range("A2:A1000")) Is Nothing Then
        ' Votre macro
    End If
End Sub
"A1000" doit être modifié ou non suivant votre contexte.

sylvanu

XLDnaute Barbatruc
Supporter XLD
Bonsoir Farid,
Il faut limiter la portée de la macro :
VB:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    If Not Application.Intersect(Target, Range("A2:A1000")) Is Nothing Then
        ' Votre macro
    End If
End Sub
"A1000" doit être modifié ou non suivant votre contexte.
 

Phil69970

XLDnaute Barbatruc
Bonjour @farid

Je te propose ceci :

VB:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim rep$, nom$, C As Range

If Not Application.Intersect(Target, Range("A1")) Is Nothing Then 'Cellule A1
    Exit Sub
Else
    If Not Application.Intersect(Target, Range("A:A")) Is Nothing Then 'col A
        Cancel = True
        rep = ActiveWorkbook.Path & "\SAUVEGARDE-OT\2022\"
        nom = Target.Value
        Call testouverture
        If Not FichierOuvert(nom & ".xlsm") = True Then
            Workbooks.Open rep & nom & ".xlsm"
            Call testouverture
        End If
       
    End If
End If
End Sub

*Explication :
Le 1er if intersect contrôle A1 et le 2eme if intersect contrôle la colonne A

*Merci de ton retour

@Phil69970
 

Discussions similaires

  • Résolu(e)
Microsoft 365 Application.run
Réponses
5
Affichages
457

Statistiques des forums

Discussions
312 071
Messages
2 085 051
Membres
102 767
dernier inscrit
jmkp