Excel: détecter la couleur de la cellule

triwix Messages postés 306 Statut Membre -  
triwix Messages postés 306 Statut Membre -
Bonjour,

Je ne trouve pas réponse à mon interrogation sur le forum.

Sur excel 2003 comment traduire la formule =si(A1 est de couleur rouge;A2;A3)

En fait ce que je veux faire c'est l'inverse d'une mise en forme conditionnelle, j'ai une macro qui colore la cellule en rouge quand je clique une fois dessus, et je voudrait donc afficher une information dans une autre cellule quand celle-ci est colorée ou non.

Je ne sais pas si je me fais bien comprendre

Merci de votre aide

A+
A voir également:

3 réponses

triwix Messages postés 306 Statut Membre 22
 
Je suis vraiment mauvais, je doit le mettre comment? j'ai essayé mais ca marche pas:

Sub coul()
If Range("A" & 1).Font.Color = vbRed Then
Range("j" & 1) = 1
End If
End Sub

ou encore:

Private Sub Worksheet_Activate()
If Range("A" & 1).Font.Color = vbRed Then
Range("j" & 1) = 1
End If
End Sub

Même résultat = rien

Merci de votre patience
0
michel_m Messages postés 18903 Date d'inscription   Statut Contributeur Dernière intervention   3 318
 
bonjour
if range("A1").interior.colorindex=3 then
range("tonautrecellule")=range("A2")
else
range("tonautrecellule")=range("A3")
end if
0
triwix Messages postés 306 Statut Membre 22
 
Ok j'ai inclu ce code à ma macro pour colorer la cellule ca marche impeccable.

le voici:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If ActiveCell.Interior.ColorIndex = 0 Then ActiveCell.Interior.ColorIndex = 3 Else ActiveCell.Interior.ColorIndex = 3
If Range("A1").Interior.ColorIndex = 3 Then
Range("J1") = 1
Cancel = True
End If
End Sub

Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
If Intersect(Target, Range("A:L")) Is Nothing Then Exit Sub
If ActiveCell.Interior.ColorIndex = xlColorIndexNone Then ActiveCell.Interior.ColorIndex = 3 Else ActiveCell.Interior.ColorIndex = xlColorIndexNone
Cancel = True
End Sub

Par contre j'ai encore 1 question: Comment effacer le cellule J1 quand A1 redevient blanche dans ma seconde macro?

Merci
0