un code pour plusieurs cellules

pascal21

XLDnaute Barbatruc
bonsoir

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Range('A1') = 'a' Then
Range('A1').Font.ColorIndex = 3
ElseIf Range('A1') = 'b' Then
Range('A1').Font.ColorIndex = 5
ElseIf Range('a1') = 'c' Then
Range('a1').Font.ColorIndex = 54
End If
End Sub

ma question comment faire pour que celà concerne une plage de cellules allant de a1 à a25 par exemple
merci
 

justine

XLDnaute Occasionnel
bonsoir le forum, pascal21
j'ai resolu ton probleme
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
For Each c In Range('a1:a25')
If c = 'a' Then
c.Font.ColorIndex = 3
ElseIf c = 'b' Then
c.Font.ColorIndex = 5
ElseIf c = 'c' Then
c.Font.ColorIndex = 54
End If
Next
End Sub
 

Dan

XLDnaute Barbatruc
Bonsoir Pascal21,

essaie ceci :

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
For Each c In Range('A1:A25')
Select Case c
Case Is = 'a'
c.Font.ColorIndex = 3
Case Is = 'b'
c.Font.ColorIndex = 5
Case Is = 'c'
c.Font.ColorIndex = 54
End Select
Next c
End Sub

Si pb n'hésite pas

;)
 

Discussions similaires

Statistiques des forums

Discussions
312 347
Messages
2 087 504
Membres
103 565
dernier inscrit
Fabien78