VBA mise en forme cellules

Bonjour au forum,

J'ai la macro suivante qui m'ouvre le fichier "extraction.xls" et fait une mise en forme ce de fichier.

Je rencontre un problème : la macro ne veut pas faire la mise en forme de la ligne "solde initial".

derligne = Cells(Rows.Count, 1).End(xlUp).Row

For i = derligne To 8 Step -1
    If Cells(i, 1) = "Solde initial" Or Cells(i, 1) = "Total recettes" Or Cells(i, 1) = "Total Dépenses" Or Cells(i, 1) = "Solde final" Then
        Rows(i).Font.Bold = True
        Range("A" & i, "M" & i).Select
        Selection.Borders(xlDiagonalDown).LineStyle = xlNone
        Selection.Borders(xlDiagonalUp).LineStyle = xlNone
        With Selection.Borders(xlEdgeLeft)
            .LineStyle = xlContinuous
            .ColorIndex = 0
            .TintAndShade = 0
            .Weight = xlMedium
        End With
        With Selection.Borders(xlEdgeTop)
            .LineStyle = xlContinuous
            .ColorIndex = 0
            .TintAndShade = 0
            .Weight = xlMedium
        End With
        With Selection.Borders(xlEdgeBottom)
            .LineStyle = xlContinuous
            .ColorIndex = 0
            .TintAndShade = 0
            .Weight = xlMedium
        End With
        With Selection.Borders(xlEdgeRight)
            .LineStyle = xlContinuous
            .ColorIndex = 0
            .TintAndShade = 0
            .Weight = xlMedium
        End With
        Selection.Borders(xlInsideVertical).LineStyle = xlNone
        Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
    Else

 End If

 Next i
 

En remerciant de votre aide.

9test.xlsm (30.97 Ko)
10extraction.zip (4.90 Ko)

Bonjour,

derligne = Cells(Rows.Count, 1).End(xlUp).Row

For i = derligne To 8 Step -1

Remplace cette ligne pour la M en Forme par celle-ci

For i = derligne To 1 Step -1

Un grand merci !

Rechercher des sujets similaires à "vba mise forme"