Microsoft 365 Stopper macro si

Francky79

XLDnaute Occasionnel
Bonjour le forum,

Comment stopper une macro suivant condition.
Je copie une couleur de cellule d'une feuille vers une autre, mais si la colonne de réception comporte Val AR dans la cellule stopper la macro.
Voir fichier en pièce ce sera plus clair.
Merci pour votre aide.
 

Pièces jointes

  • Copie état.xlsm
    28.3 KB · Affichages: 4
Solution
Salut,
testez le code ci dessous :
VB:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Not Intersect(Target, Range("AD6:AD1000")) Is Nothing Then
    Dim lig As Variant
    Cancel = True
    Target = Date
    With Sheets("Base")
        lig = Application.Match(Cells(Target.Row, "A"), .Columns("E"), 0)
        If IsNumeric(lig) Then
            With .Cells(lig, "Q")
                If .Value <> "Val AR" Then
                    .Interior.Color = Cells(Target.Row, "AR").DisplayFormat.Interior.Color
                    .Font.Color = Cells(Target.Row, "AR").DisplayFormat.Font.Color
                    .Value = Cells(Target.Row, "AR").Value
                End If
            End With
        End If
    End...

fanch55

XLDnaute Barbatruc
Salut,
testez le code ci dessous :
VB:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Not Intersect(Target, Range("AD6:AD1000")) Is Nothing Then
    Dim lig As Variant
    Cancel = True
    Target = Date
    With Sheets("Base")
        lig = Application.Match(Cells(Target.Row, "A"), .Columns("E"), 0)
        If IsNumeric(lig) Then
            With .Cells(lig, "Q")
                If .Value <> "Val AR" Then
                    .Interior.Color = Cells(Target.Row, "AR").DisplayFormat.Interior.Color
                    .Font.Color = Cells(Target.Row, "AR").DisplayFormat.Font.Color
                    .Value = Cells(Target.Row, "AR").Value
                End If
            End With
        End If
    End With
End If
End Sub
 

Statistiques des forums

Discussions
312 211
Messages
2 086 299
Membres
103 173
dernier inscrit
Cerba95