Appliquer deux macro dans une feuille

Bonsoir

Sur Mon document Excel, j'ai une macro qui se lance lorsque l'on clique sur un bouton.

Elle se lance donc ainsi :

Private Sub cmdAlimLesCasesFeuille_Click()
    Worksheets("Bla").Cells(1, 13) = txtEcritFeuille.Value

Dim j As Long
Dim myLastRow As Long

j = Range("Q1").Value
myLastRow = Cells(Rows.Count, "A").End(xlUp).Row

[a35].Resize(j, 4).EntireRow.Insert
[a34].Resize(j, 4).EntireRow.Insert
[a33].Resize(j, 4).EntireRow.Insert

Etc.

Une fois la macro appliquée, il reste des cases à remplir, que je rempli.

Comment faire pour qu'une autre macro s'active en fond, dès qu'une modification est effectuée dans les colonnes J, K et M ?

J'ai testé ça :

Private Sub Worksheet_Change (ByVal Target As Range)

    For f = 4 To 110

            If Cells(f, 11) = "Très fort" Then
                Range(Cells(f, 11), Cells(f, 11)).Interior.Color = RGB(192, 0, 0)
                Range(Cells(f, 11), Cells(f, 11)).Font.Color = RGB(255, 255, 255)
            Else
                If Cells(f, 11) = "Fort" Then
                    Range(Cells(d, 11), Cells(d, 11)).Interior.Color = RGB(255, 0, 0)
                Else
                    If Cells(f, 11) = "Modéré" Then
                         Range(Cells(f, 11), Cells(d, 11)).Interior.Color = RGB(255, 192, 0)
                    Else
                         If Cells(f, 11) = "Faible" Then
                           Range(Cells(f, 11), Cells(f, 11)).Interior.Color = RGB(255, 255, 153)
                         Else
                             If Cells(f, 11) = "Très faible" Then
                               Range(Cells(f, 11), Cells(f, 11)).Interior.Color = RGB(255, 255, 255)
                               Range(Cells(f, 11), Cells(f, 11)).Font.Color = RGB(0, 0, 0)
             End If
                End If
                    End If
                       End If
                            End If
    Next

Etc.

End Sub

Sans succès.

Comment devrais-je utiliser "Worksheet_Change" d'après vous ?

J'ai l'impression qu'il faut que je préciser "lorsque la colonne J, K ou M est modifiée".

Bonne fin de soirée !

A plus tard.

bonjour,

pour executer une partie du code si la colonne est j,k ou m

Private Sub Worksheet_Change(ByVal Target As Range)
    Select Case Target.Column
    Case 10, 11, 13
        'colonne j,k et m
        For f = 4 To 110
            If Cells(f, 11) = "Très fort" Then
                Range(Cells(f, 11), Cells(f, 11)).Interior.Color = RGB(192, 0, 0)
                Range(Cells(f, 11), Cells(f, 11)).Font.Color = RGB(255, 255, 255)
            Else
                If Cells(f, 11) = "Fort" Then
                    Range(Cells(d, 11), Cells(d, 11)).Interior.Color = RGB(255, 0, 0)
                Else
                    If Cells(f, 11) = "Modéré" Then
                        Range(Cells(f, 11), Cells(d, 11)).Interior.Color = RGB(255, 192, 0)
                    Else
                        If Cells(f, 11) = "Faible" Then
                            Range(Cells(f, 11), Cells(f, 11)).Interior.Color = RGB(255, 255, 153)
                        Else
                            If Cells(f, 11) = "Très faible" Then
                                Range(Cells(f, 11), Cells(f, 11)).Interior.Color = RGB(255, 255, 255)
                                Range(Cells(f, 11), Cells(f, 11)).Font.Color = RGB(0, 0, 0)
                            End If
                        End If
                    End If
                End If
            End If
        Next

        'etc ...
    End Select
End Sub

Bonjour,

Merci de votre réponse.

Tout fonctionne parfaitement désormais !

Rechercher des sujets similaires à "appliquer deux macro feuille"