Private Sub ComboBox1_Change()
Dim i As Variant
With ComboBox1
If .ListIndex = -1 Then Exit Sub
ActiveCell = IIf(.ListIndex = 0, "", Replace(.Text, vbCrLf, vbLf))
i = Application.Match(ActiveCell, ActiveCell(1, 4).Resize(, 12), 0)
If IsError(i) Then ActiveCell.Interior.ColorIndex = xlNone Else ActiveCell.Interior.Color = ActiveCell(1, 3 + i).Interior.Color
ActiveCell(1, 0).Select
End With
End Sub
Super c'est exactement ce que je voulais faire. vraiment encore merci pour toutS'il s'agit de colorer la cellule active avec la couleur de la cellule copiée, voyez ce fichier (4) avec :
Il faut savoir que dans la ComboBox vbLf - CAR(10) - est transformé en vbCrLf - CAR(13)&CAR(10).VB:Private Sub ComboBox1_Change() Dim i As Variant With ComboBox1 If .ListIndex = -1 Then Exit Sub ActiveCell = IIf(.ListIndex = 0, "", Replace(.Text, vbCrLf, vbLf)) i = Application.Match(ActiveCell, ActiveCell(1, 4).Resize(, 12), 0) If IsError(i) Then ActiveCell.Interior.ColorIndex = xlNone Else ActiveCell.Interior.Color = ActiveCell(1, 3 + i).Interior.Color ActiveCell(1, 0).Select End With End Sub
Donc quand on copie le texte de la ComboBox il faut remplacer vbCrLf par vbLf.
A+