Vous utilisez un navigateur obsolète. Il se peut que ce site ou d'autres sites Web ne s'affichent pas correctement. Vous devez le mettre à jour ou utiliser un navigateur alternatif.
Comment colorer les cellules quand je saisis dans différentes colonnes ?
Boostez vos compétences Excel avec notre communauté !
Rejoignez Excel Downloads, le rendez-vous des passionnés où l'entraide fait la force.
Apprenez, échangez, progressez – et tout ça gratuitement !
👉 Inscrivez-vous maintenant !
Option Explicit
Private Sub Worksheet_Change(ByVal c As Range)
Dim plage As Range
Set plage = Range("B:B,D:D,F:F,G:G")
If c.Count > 1 Then Exit Sub
If Not Intersect(c, plage) Is Nothing Then
Select Case c
Case Is <> "": c.Interior.ColorIndex = 4: Case Else: c.Interior.ColorIndex = xlNone
End Select
End If
End Sub
j'ai déjà ce code dans la page, je veux l'agréger, et fatalement il y a une erreur, je continue de chercher...
VB:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Cancel = True
With Target
If .Column = 2 Then
Cancel = True
If .Comment Is Nothing Then
.AddComment
.Comment.Shape.Width = 241.5
.Comment.Shape.Height = 99.75
End If
SendKeys "%im"
End If
If .Column = 3 Then
Cancel = True
If .Comment Is Nothing Then
.AddComment
.Comment.Shape.Width = 241.5
.Comment.Shape.Height = 99.75
End If
SendKeys "%im"
End If
If .Column = 4 Then
Cancel = True
If .Comment Is Nothing Then
.AddComment
.Comment.Shape.Width = 241.5
.Comment.Shape.Height = 99.75
End If
SendKeys "%im"
End If
If .Column = 5 Then
Cancel = True
If .Comment Is Nothing Then
.AddComment
.Comment.Shape.Width = 241.5
.Comment.Shape.Height = 99.75
End If
SendKeys "%im"
End If
If .Column = 6 Then
Cancel = True
If .Comment Is Nothing Then
.AddComment
.Comment.Shape.Width = 241.5
.Comment.Shape.Height = 99.75
End If
SendKeys "%im"
End If
If .Column = 7 Then
Cancel = True
If .Comment Is Nothing Then
.AddComment
.Comment.Shape.Width = 241.5
.Comment.Shape.Height = 99.75
End If
SendKeys "%im"
End If
If .Column = 8 Then
Cancel = True
If .Comment Is Nothing Then
.AddComment
.Comment.Shape.Width = 241.5
.Comment.Shape.Height = 99.75
End If
SendKeys "%im"
End If
If .Column = 9 Then
Cancel = True
If .Comment Is Nothing Then
.AddComment
.Comment.Shape.Width = 241.5
.Comment.Shape.Height = 99.75
End If
SendKeys "%im"
End If
End With
With Target
If .Column = 4 Then
Cancel = True
If .Comment Is Nothing Then
.AddComment
.Comment.Shape.Width = 279.5
.Comment.Shape.Height = 130.75
End If
SendKeys "%im"
End If
End With
End Sub
Si je n'y parviens pas, je reviens avec ce que j'ai fait de ton code et de ce dernier.
@Marcel32 , pour ce qui est de la MFC je ne vois pas ?
Option Explicit
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Cancel = True
With Target
If .Column > 1 And .Column < 10 Then
If .Comment Is Nothing Then
.AddComment
.Comment.Shape.Width = 241.5
.Comment.Shape.Height = 99.75
SendKeys "%im"
End If
End If
End With
Application.SendKeys "{NUMLOCK}", True ' clavier numérique activer
End Sub
- Navigue sans publicité - Accède à Cléa, notre assistante IA experte Excel... et pas que... - Profite de fonctionnalités exclusives Ton soutien permet à Excel Downloads de rester 100% gratuit et de continuer à rassembler les passionnés d'Excel. Je deviens Supporter XLD