Assembler 3 macros sur la même feuille

Bonjour à tous,

Je vous remercie par avance de vous pencher sur ma problématique et potentiellement d'y apporter une réponse.

Je souhaiterais savoir s'il est possible d'assembler les 3 macros suivantes sur la même feuille. Et auquel cas, si pouviez me montrer le résultat.

Macro 1 Colorer cellule modifiée

Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Count > 1 Then Exit Sub

If Not Application.Intersect(Target, Range("DATA")) Is Nothing Then

Target.Interior.ColorIndex = 3

End If

End Sub

Macro 2 Afficher date de modification

Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Row > 1 Then Cells(Target.Row, "Q") = Now()

End Sub

Macro 3 Mettre en évidence la ligne sélectionnée

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Set champ = Range("DATA")

If Not Intersect(champ, Target) Is Nothing And Target.Count = 1 Then

champ.Interior.ColorIndex = xlNone

col1 = champ.Column

col2 = col1 + champ.Columns.Count - 1

Range(Cells(Target.Row, col1), Cells(Target.Row, col2)).Interior.ColorIndex = 36

End If

End Sub

Merci pour vos explications !

Bonjour,

à tester

Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Count > 1 Then Exit Sub
    If Not Application.Intersect(Target, Range("DATA")) Is Nothing Then
        Target.Interior.ColorIndex = 3
    End If
    If Target.Row > 1 Then
        Application.EnableEvents = False
        Cells(Target.Row, "Q") = Now()
        Application.EnableEvents = True
    End If
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Set champ = Range("DATA")
    If Not Intersect(champ, Target) Is Nothing And Target.Count = 1 Then
        champ.Interior.ColorIndex = xlNone
        col1 = champ.Column
        col2 = col1 + champ.Columns.Count - 1
        Range(Cells(Target.Row, col1), Cells(Target.Row, col2)).Interior.ColorIndex = 36
    End If
End Sub

On progresse ! Deux macros fonctionnent. En revanche la macro permettant de colorer une cellule qui est modifié ne reste pas :/

Aurais-tu une solution ?

Bonjour,

la question est-elle toujours d'actualité ?

Rechercher des sujets similaires à "assembler macros meme feuille"