Macro Excel ajouter caractère selon 2 conditions

Bonjour,

je sollicite votre aide pour une macro Excel.

J'ai un tableau de 6 colonnes.

Merci de votre aide.

Bonne journée.

17test-01.xlsm (14.97 Ko)

bonjour,

une solution possible

Sub aargh()
    With Sheets("feuil1")
        For i = 2 To .Cells(Rows.Count, 2).End(xlUp).Row
            If Left(.Cells(i, 1), 3) = "CCV" Then
            col = .Cells(i, Columns.Count).End(xlToLeft).Column
                For k = 2 To col
                    If .Cells(i, k).Interior.Color = vbRed Then
                        For j = -11 To 11
                            If j <> 0 And .Cells(i + j, k) <> "" Then
                                .Cells(i + j, k) = Format(.Cells(i + j, k), "##0.00%") & "C"
                            End If
                        Next j
                    End If
                Next k
            End If
        Next i
    End With
End Sub

Bonjour h2so4,

C'est parfait !!

Merci beaucoup pour votre aide.

Bonne journée.

bonjour,

j'ai corrigé un bug

Sub aargh()
    With Sheets("feuil1")
        For i = 2 To .Cells(Rows.Count, 2).End(xlUp).Row Step 12
            If Left(.Cells(i, 1), 3) = "CCV" Then
            col = .Cells(i, Columns.Count).End(xlToLeft).Column
                For k = 3 To col
                    If .Cells(i, k).Interior.Color = vbRed Then
                        For j = -11 To 11
                            If j <> 0 And .Cells(i + j, k) <> "" And InStr(.Cells(i + j, k), "C") = 0 Then
                                .Cells(i + j, k) = Format(.Cells(i + j, k), "##0.00%") & "C"
                            End If
                        Next j
                    End If
                Next k
            End If
        Next i
    End With
End Sub
 
Rechercher des sujets similaires à "macro ajouter caractere conditions"