Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

Re: mise a jour colonnes

2 réponses
Avatar
andre
Bonjour,
je reviens par rapport au post du 30/10 "mise a jour colone"
j'ai finalement mis ce code dans un module (il fonctionne)
Sub Change_color()
For Each c In Range("F2:F1200")
If UCase(c) Like "V" Then c.Interior.ColorIndex = 43
If UCase(c) Like "V" Then c.Font.ColorIndex = 3
If UCase(c) Like "V" Then c.Font.Bold = True
If UCase(c) Like "A" Then c.Interior.ColorIndex = 20
If UCase(c) Like "A" Then c.Font.ColorIndex = 5
If UCase(c) Like "A" Then c.Font.Bold = True
If UCase(c) Like "C" Then c.Interior.ColorIndex = 24
If UCase(c) Like "C" Then c.Font.ColorIndex = 1
If UCase(c) Like "C" Then c.Font.Bold = True
Next
For Each c In Range("G2:G1200")
If UCase(c) Like "P" Then c.Interior.ColorIndex = 4
If UCase(c) Like "P" Then c.Font.ColorIndex = 5
If UCase(c) Like "P" Then c.Font.Bold = True
If UCase(c) Like "E" Then c.Interior.ColorIndex = 6
If UCase(c) Like "E" Then c.Font.ColorIndex = 3
If UCase(c) Like "E" Then c.Font.Bold = True
Next
End Sub
ma question y avait il plus simple par ex rajout d'un bout de code
dans la feuille ce qui m'aurait evité le module et un bouton de
commande
et en plus c'est un peu longuet
merci a vous bon dimanche

--
andre

2 réponses

Avatar
FFO
Salut andre

Tu peux mettre dans le VBA de ta feuille ce code :

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 6 And Target.Row > 1 And Target.Row < 1201 Then
If UCase(Target) Like "V" Then
Target.Interior.ColorIndex = 43
Target.Font.ColorIndex = 3
Target.Font.Bold = True
End If
If UCase(Target) Like "A" Then
Target.Interior.ColorIndex = 20
Target.Font.ColorIndex = 5
Target.Font.Bold = True
End If
If UCase(Target) Like "C" Then
Target.Interior.ColorIndex = 24
Target.Font.ColorIndex = 1
Target.Font.Bold = True
End If
End If
If Target.Column = 7 And Target.Row > 1 And Target.Row < 1201 Then
If UCase(Target) Like "P" Then
Target.Interior.ColorIndex = 4
Target.Font.ColorIndex = 5
Target.Font.Bold = True
End If
If UCase(Target) Like "E" Then
Target.Interior.ColorIndex = 6
Target.Font.ColorIndex = 3
Target.Font.Bold = True
End If
End If
End Sub

A chaque modification des cellules colonne F et G de la ligne 2 à 1200 si la
saisie correspond à un des critères la mise en forme se fera automatiquement
Attention une seule cellule à la fois
On ne peux pas par exemple réaliser un copier coller sur plusieurs cellules
d'un paramètre qui engendrerait ces mises en forme (Bug)

De plus ce code est à rapporter dans le VBA de chaque feuille dont tu
souhaites bénéficier de cet automatisme

Celà devrait te convenir
Dis moi !!!!
Avatar
andre
Ok merci
je mets tout cela en forme demain
etje te redis
bonne nuit et bon dim
a+

--
andre