Private Sub CommandButton1_Click() Dim laplage As Range, cel As Range For Each cel In Range("D:D").SpecialCells(xlCellTypeConstants) If cel.Value = "&" Then If laplage Is Nothing Then Set laplage = cel Else Set laplage = Union(laplage, cel) End If End If Next mise_en_forme laplage End Sub Sub mise_en_forme(p As Range) Dim r As Range For Each r In p For i = 0 To 5 r.Offset(0, i).Interior.ColorIndex = 8 Next Next End Sub
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionpourriez vous m écrire un bout de code ....
Dim derligne As Long, i As Long derligne Range("A" & Rows.Count).End(xlUp).Row '>> pour déterminer la dernière ligne remplie de ta colonne A For i = 1 To derligne If Range("A" & i).Value = "&" Then Range("A" & i).Select MsgBox "en voilà une" End If Next
Private Sub CommandButton1_Click() Dim derligne As Long, i As Long derligne Range("D" & Rows.Count).End(xlUp).Row '>> pour déterminer la dernière ligne remplie de ta colonne A For i = 1 To derligne If Range("D" & i).Value = "&" Then mise_en_forme_lourde Range("D" & i) End If Next End Sub Sub mise_en_forme_lourde(p As Range) Dim i As Range For i = 0 To 5 p.Offset(0, i).Interior.ColorIndex = 5 Next End Sub
Private Sub CommandButton1_Click() Dim laplage As Range, cel As Range For Each cel In Range("D:D").SpecialCells(xlCellTypeConstants) If cel.Value = "&" Then If laplage Is Nothing Then Set laplage = Union(cel, cel.Offset(0, 1), cel.Offset(0, 2), cel.Offset(0, 3), cel.Offset(0, 4), cel.Offset(0, 5)) Else Set laplage = Union(laplage, cel, cel.Offset(0, 1), cel.Offset(0, 2), cel.Offset(0, 3), cel.Offset(0, 4), cel.Offset(0, 5)) End If End If Next mise_en_forme laplage End Sub Sub mise_en_forme(p As Range) p.Interior.ColorIndex = 6 End Sub