Ceci va bien :Est-il possible de l'adapter pour que plutôt d'avoir une plage de cellule A1:A10
Je choisisse exemple :
B2=CHVSGRI
B3=Campus de Bla bla
G15=NCHCHTTF12
Etc
Private Sub Worksheet_Change(ByVal Target As Range)
Dim a, b, i
a = Array("B2", "B3", "G15") 'à adapter
b = Array("CHVSGRI", "Campus de Bla bla", "NCHCHTTF12") 'à adapter
For i = 0 To UBound(a)
If Range(a(i)) = "" Then
Range(a(i)).Font.ColorIndex = 16
Range(a(i)).Font.Bold = False 'non gras
Range(a(i)) = b(i)
ElseIf Range(a(i)) <> b(i) Then
Range(a(i)).Font.ColorIndex = xlAutomatic
Range(a(i)).Font.Bold = True 'gras, facultatif
End If
Next
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
Dim a, b, i
a = Array("C11", "C12", "F24") 'à adapter
b = Array("CHVSGRI", "100,200,300", "100") 'à adapter
For i = 0 To UBound(a)
If Range(a(i)) = "" Then
Range(a(i)).Font.ColorIndex = 18
Range(a(i)).Font.Bold = False 'non gras
Range(a(i)) = b(i)
ElseIf Range(a(i)) <> b(i) Then
Range(a(i)).Font.ColorIndex = 18
Range(a(i)).Font.Bold = False 'gras, facultatif
End If
Next
End Sub
100'200'300 |
En VBA la virgule est le séparateur des milliers, pour l'éviter utiliser le format Texte :exemple = "100,200,300", "100"
Private Sub Worksheet_Change(ByVal Target As Range)
Dim a, b, i
a = Array("C11", "C12", "F24") 'à adapter
b = Array("CHVSGRI", "100,200,300", "100") 'à adapter
For i = 0 To UBound(a)
If Range(a(i)) = "" Then
Range(a(i)).NumberFormat = "@" 'format Texte
Range(a(i)).Font.ColorIndex = 18
Range(a(i)).Font.Bold = False 'non gras
Range(a(i)) = b(i)
ElseIf Range(a(i)) <> b(i) Then
Range(a(i)).NumberFormat = "General" 'format Standard
Range(a(i)).Font.ColorIndex = Automatic
Range(a(i)).Font.Bold = False 'gras, facultatif
End If
Next
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
Dim a, b, i
a = Array("C11", "C12", "F24") 'à adapter
b = Array("CHVSGRI", "100,200,300", "100") 'à adapter
For i = 0 To UBound(a)
b(i) = Replace(b(i), ",", Chr(130))
If Range(a(i)) = "" Then
Range(a(i)).Font.ColorIndex = 18
Range(a(i)).Font.Bold = False 'non gras
Range(a(i)) = b(i)
ElseIf Range(a(i)) <> b(i) Then
Range(a(i)).Font.ColorIndex = Automatic
Range(a(i)).Font.Bold = False 'gras, facultatif
End If
Next
End Sub