Je souhaite formater des cellules après choix dans une liste déroulante.
Cela fonctionne pour une seule cellule. Le problème est que si je recopie le
contenu d'une des cellules la macro plante ou ne fonctionne plus (erreur 13).
Le code :
Private Sub Worksheet_Change(ByVal Target As Range)
If Target = "" Then
Target.Interior.ColorIndex = xlNone
ElseIf Target = "Congés" Then
Target.Interior.ColorIndex = 8
Target.Font.ColorIndex = 8
ElseIf Target = "RTT" Then
Target.Interior.ColorIndex = 44
Target.Font.ColorIndex = 44
ElseIf Target = "Récup" Then
Target.Interior.ColorIndex = 4
Target.Font.ColorIndex = 4
ElseIf Target = "Maladie" Then
Target.Interior.ColorIndex = 5
Target.Font.ColorIndex = 5
End If
End Sub
Cette action est irreversible, confirmez la suppression du commentaire ?
Signaler le commentaire
Veuillez sélectionner un problème
Nudité
Violence
Harcèlement
Fraude
Vente illégale
Discours haineux
Terrorisme
Autre
lSteph
Bonjour Camille,
Private Sub Worksheet_Change(ByVal Target As Range) Dim c As Range For Each c In Target.Cells With c Select Case .Value Case "" .Interior.ColorIndex = xlNone Case "Congés" .Interior.ColorIndex = 8 .Font.ColorIndex = 8 Case "RTT" .Interior.ColorIndex = 44 .Font.ColorIndex = 44 Case "Récup" .Interior.ColorIndex = 4 .Font.ColorIndex = 4 Case "Maladie" c.Interior.ColorIndex = 5 c.Font.ColorIndex = 5 End Select End With Next End Sub
'Cdlt 'lSteph
On 18 sep, 15:50, Ellimac wrote:
Bonjour,
Je souhaite formater des cellules après choix dans une liste déroulan te. Cela fonctionne pour une seule cellule. Le problème est que si je recop ie le contenu d'une des cellules la macro plante ou ne fonctionne plus (erreur 13). Le code :
Private Sub Worksheet_Change(ByVal Target As Range) If Target = "" Then Target.Interior.ColorIndex = xlNone ElseIf Target = "Congés" Then Target.Interior.ColorIndex = 8 Target.Font.ColorIndex = 8 ElseIf Target = "RTT" Then Target.Interior.ColorIndex = 44 Target.Font.ColorIndex = 44 ElseIf Target = "Récup" Then Target.Interior.ColorIndex = 4 Target.Font.ColorIndex = 4 ElseIf Target = "Maladie" Then Target.Interior.ColorIndex = 5 Target.Font.ColorIndex = 5 End If End Sub
Merci Camille
Bonjour Camille,
Private Sub Worksheet_Change(ByVal Target As Range)
Dim c As Range
For Each c In Target.Cells
With c
Select Case .Value
Case ""
.Interior.ColorIndex = xlNone
Case "Congés"
.Interior.ColorIndex = 8
.Font.ColorIndex = 8
Case "RTT"
.Interior.ColorIndex = 44
.Font.ColorIndex = 44
Case "Récup"
.Interior.ColorIndex = 4
.Font.ColorIndex = 4
Case "Maladie"
c.Interior.ColorIndex = 5
c.Font.ColorIndex = 5
End Select
End With
Next
End Sub
'Cdlt
'lSteph
On 18 sep, 15:50, Ellimac <Elli...@discussions.microsoft.com> wrote:
Bonjour,
Je souhaite formater des cellules après choix dans une liste déroulan te.
Cela fonctionne pour une seule cellule. Le problème est que si je recop ie le
contenu d'une des cellules la macro plante ou ne fonctionne plus (erreur 13).
Le code :
Private Sub Worksheet_Change(ByVal Target As Range)
If Target = "" Then
Target.Interior.ColorIndex = xlNone
ElseIf Target = "Congés" Then
Target.Interior.ColorIndex = 8
Target.Font.ColorIndex = 8
ElseIf Target = "RTT" Then
Target.Interior.ColorIndex = 44
Target.Font.ColorIndex = 44
ElseIf Target = "Récup" Then
Target.Interior.ColorIndex = 4
Target.Font.ColorIndex = 4
ElseIf Target = "Maladie" Then
Target.Interior.ColorIndex = 5
Target.Font.ColorIndex = 5
End If
End Sub
Private Sub Worksheet_Change(ByVal Target As Range) Dim c As Range For Each c In Target.Cells With c Select Case .Value Case "" .Interior.ColorIndex = xlNone Case "Congés" .Interior.ColorIndex = 8 .Font.ColorIndex = 8 Case "RTT" .Interior.ColorIndex = 44 .Font.ColorIndex = 44 Case "Récup" .Interior.ColorIndex = 4 .Font.ColorIndex = 4 Case "Maladie" c.Interior.ColorIndex = 5 c.Font.ColorIndex = 5 End Select End With Next End Sub
'Cdlt 'lSteph
On 18 sep, 15:50, Ellimac wrote:
Bonjour,
Je souhaite formater des cellules après choix dans une liste déroulan te. Cela fonctionne pour une seule cellule. Le problème est que si je recop ie le contenu d'une des cellules la macro plante ou ne fonctionne plus (erreur 13). Le code :
Private Sub Worksheet_Change(ByVal Target As Range) If Target = "" Then Target.Interior.ColorIndex = xlNone ElseIf Target = "Congés" Then Target.Interior.ColorIndex = 8 Target.Font.ColorIndex = 8 ElseIf Target = "RTT" Then Target.Interior.ColorIndex = 44 Target.Font.ColorIndex = 44 ElseIf Target = "Récup" Then Target.Interior.ColorIndex = 4 Target.Font.ColorIndex = 4 ElseIf Target = "Maladie" Then Target.Interior.ColorIndex = 5 Target.Font.ColorIndex = 5 End If End Sub
Je souhaite formater des cellules après choix dans une liste déroulan te. Cela fonctionne pour une seule cellule. Le problème est que si je recop ie le contenu d'une des cellules la macro plante ou ne fonctionne plus (erreur 13). Le code :
Private Sub Worksheet_Change(ByVal Target As Range) If Target = "" Then Target.Interior.ColorIndex = xlNone ElseIf Target = "Congés" Then Target.Interior.ColorIndex = 8 Target.Font.ColorIndex = 8 ElseIf Target = "RTT" Then Target.Interior.ColorIndex = 44 Target.Font.ColorIndex = 44 ElseIf Target = "Récup" Then Target.Interior.ColorIndex = 4 Target.Font.ColorIndex = 4 ElseIf Target = "Maladie" Then Target.Interior.ColorIndex = 5 Target.Font.ColorIndex = 5 End If End Sub
On 18 sep, 15:50, Ellimac <Elli...@discussions.microsoft.com> wrote:
Bonjour,
Je souhaite formater des cellules après choix dans une liste déroulan te.
Cela fonctionne pour une seule cellule. Le problème est que si je recop ie le
contenu d'une des cellules la macro plante ou ne fonctionne plus (erreur 13).
Le code :
Private Sub Worksheet_Change(ByVal Target As Range)
If Target = "" Then
Target.Interior.ColorIndex = xlNone
ElseIf Target = "Congés" Then
Target.Interior.ColorIndex = 8
Target.Font.ColorIndex = 8
ElseIf Target = "RTT" Then
Target.Interior.ColorIndex = 44
Target.Font.ColorIndex = 44
ElseIf Target = "Récup" Then
Target.Interior.ColorIndex = 4
Target.Font.ColorIndex = 4
ElseIf Target = "Maladie" Then
Target.Interior.ColorIndex = 5
Target.Font.ColorIndex = 5
End If
End Sub
Je souhaite formater des cellules après choix dans une liste déroulan te. Cela fonctionne pour une seule cellule. Le problème est que si je recop ie le contenu d'une des cellules la macro plante ou ne fonctionne plus (erreur 13). Le code :
Private Sub Worksheet_Change(ByVal Target As Range) If Target = "" Then Target.Interior.ColorIndex = xlNone ElseIf Target = "Congés" Then Target.Interior.ColorIndex = 8 Target.Font.ColorIndex = 8 ElseIf Target = "RTT" Then Target.Interior.ColorIndex = 44 Target.Font.ColorIndex = 44 ElseIf Target = "Récup" Then Target.Interior.ColorIndex = 4 Target.Font.ColorIndex = 4 ElseIf Target = "Maladie" Then Target.Interior.ColorIndex = 5 Target.Font.ColorIndex = 5 End If End Sub
Merci Camille
Ellimac
Bonjour,
Merci beaucoup
Camille
Bonjour Camille,
Private Sub Worksheet_Change(ByVal Target As Range) Dim c As Range For Each c In Target.Cells With c Select Case .Value Case "" .Interior.ColorIndex = xlNone Case "Congés" .Interior.ColorIndex = 8 .Font.ColorIndex = 8 Case "RTT" .Interior.ColorIndex = 44 .Font.ColorIndex = 44 Case "Récup" .Interior.ColorIndex = 4 .Font.ColorIndex = 4 Case "Maladie" c.Interior.ColorIndex = 5 c.Font.ColorIndex = 5 End Select End With Next End Sub
'Cdlt 'lSteph
On 18 sep, 15:50, Ellimac wrote:
Bonjour,
Je souhaite formater des cellules après choix dans une liste déroulante. Cela fonctionne pour une seule cellule. Le problème est que si je recopie le contenu d'une des cellules la macro plante ou ne fonctionne plus (erreur 13). Le code :
Private Sub Worksheet_Change(ByVal Target As Range) If Target = "" Then Target.Interior.ColorIndex = xlNone ElseIf Target = "Congés" Then Target.Interior.ColorIndex = 8 Target.Font.ColorIndex = 8 ElseIf Target = "RTT" Then Target.Interior.ColorIndex = 44 Target.Font.ColorIndex = 44 ElseIf Target = "Récup" Then Target.Interior.ColorIndex = 4 Target.Font.ColorIndex = 4 ElseIf Target = "Maladie" Then Target.Interior.ColorIndex = 5 Target.Font.ColorIndex = 5 End If End Sub
Merci Camille
Bonjour,
Merci beaucoup
Camille
Bonjour Camille,
Private Sub Worksheet_Change(ByVal Target As Range)
Dim c As Range
For Each c In Target.Cells
With c
Select Case .Value
Case ""
.Interior.ColorIndex = xlNone
Case "Congés"
.Interior.ColorIndex = 8
.Font.ColorIndex = 8
Case "RTT"
.Interior.ColorIndex = 44
.Font.ColorIndex = 44
Case "Récup"
.Interior.ColorIndex = 4
.Font.ColorIndex = 4
Case "Maladie"
c.Interior.ColorIndex = 5
c.Font.ColorIndex = 5
End Select
End With
Next
End Sub
'Cdlt
'lSteph
On 18 sep, 15:50, Ellimac <Elli...@discussions.microsoft.com> wrote:
Bonjour,
Je souhaite formater des cellules après choix dans une liste déroulante.
Cela fonctionne pour une seule cellule. Le problème est que si je recopie le
contenu d'une des cellules la macro plante ou ne fonctionne plus (erreur 13).
Le code :
Private Sub Worksheet_Change(ByVal Target As Range)
If Target = "" Then
Target.Interior.ColorIndex = xlNone
ElseIf Target = "Congés" Then
Target.Interior.ColorIndex = 8
Target.Font.ColorIndex = 8
ElseIf Target = "RTT" Then
Target.Interior.ColorIndex = 44
Target.Font.ColorIndex = 44
ElseIf Target = "Récup" Then
Target.Interior.ColorIndex = 4
Target.Font.ColorIndex = 4
ElseIf Target = "Maladie" Then
Target.Interior.ColorIndex = 5
Target.Font.ColorIndex = 5
End If
End Sub
Private Sub Worksheet_Change(ByVal Target As Range) Dim c As Range For Each c In Target.Cells With c Select Case .Value Case "" .Interior.ColorIndex = xlNone Case "Congés" .Interior.ColorIndex = 8 .Font.ColorIndex = 8 Case "RTT" .Interior.ColorIndex = 44 .Font.ColorIndex = 44 Case "Récup" .Interior.ColorIndex = 4 .Font.ColorIndex = 4 Case "Maladie" c.Interior.ColorIndex = 5 c.Font.ColorIndex = 5 End Select End With Next End Sub
'Cdlt 'lSteph
On 18 sep, 15:50, Ellimac wrote:
Bonjour,
Je souhaite formater des cellules après choix dans une liste déroulante. Cela fonctionne pour une seule cellule. Le problème est que si je recopie le contenu d'une des cellules la macro plante ou ne fonctionne plus (erreur 13). Le code :
Private Sub Worksheet_Change(ByVal Target As Range) If Target = "" Then Target.Interior.ColorIndex = xlNone ElseIf Target = "Congés" Then Target.Interior.ColorIndex = 8 Target.Font.ColorIndex = 8 ElseIf Target = "RTT" Then Target.Interior.ColorIndex = 44 Target.Font.ColorIndex = 44 ElseIf Target = "Récup" Then Target.Interior.ColorIndex = 4 Target.Font.ColorIndex = 4 ElseIf Target = "Maladie" Then Target.Interior.ColorIndex = 5 Target.Font.ColorIndex = 5 End If End Sub
Je souhaite formater des cellules après choix dans une liste déroulante. Cela fonctionne pour une seule cellule. Le problème est que si je recopie le contenu d'une des cellules la macro plante ou ne fonctionne plus (erreur 13). Le code :
Private Sub Worksheet_Change(ByVal Target As Range) If Target = "" Then Target.Interior.ColorIndex = xlNone ElseIf Target = "Congés" Then Target.Interior.ColorIndex = 8 Target.Font.ColorIndex = 8 ElseIf Target = "RTT" Then Target.Interior.ColorIndex = 44 Target.Font.ColorIndex = 44 ElseIf Target = "Récup" Then Target.Interior.ColorIndex = 4 Target.Font.ColorIndex = 4 ElseIf Target = "Maladie" Then Target.Interior.ColorIndex = 5 Target.Font.ColorIndex = 5 End If End Sub
On 18 sep, 15:50, Ellimac <Elli...@discussions.microsoft.com> wrote:
Bonjour,
Je souhaite formater des cellules après choix dans une liste déroulante.
Cela fonctionne pour une seule cellule. Le problème est que si je recopie le
contenu d'une des cellules la macro plante ou ne fonctionne plus (erreur 13).
Le code :
Private Sub Worksheet_Change(ByVal Target As Range)
If Target = "" Then
Target.Interior.ColorIndex = xlNone
ElseIf Target = "Congés" Then
Target.Interior.ColorIndex = 8
Target.Font.ColorIndex = 8
ElseIf Target = "RTT" Then
Target.Interior.ColorIndex = 44
Target.Font.ColorIndex = 44
ElseIf Target = "Récup" Then
Target.Interior.ColorIndex = 4
Target.Font.ColorIndex = 4
ElseIf Target = "Maladie" Then
Target.Interior.ColorIndex = 5
Target.Font.ColorIndex = 5
End If
End Sub
Je souhaite formater des cellules après choix dans une liste déroulante. Cela fonctionne pour une seule cellule. Le problème est que si je recopie le contenu d'une des cellules la macro plante ou ne fonctionne plus (erreur 13). Le code :
Private Sub Worksheet_Change(ByVal Target As Range) If Target = "" Then Target.Interior.ColorIndex = xlNone ElseIf Target = "Congés" Then Target.Interior.ColorIndex = 8 Target.Font.ColorIndex = 8 ElseIf Target = "RTT" Then Target.Interior.ColorIndex = 44 Target.Font.ColorIndex = 44 ElseIf Target = "Récup" Then Target.Interior.ColorIndex = 4 Target.Font.ColorIndex = 4 ElseIf Target = "Maladie" Then Target.Interior.ColorIndex = 5 Target.Font.ColorIndex = 5 End If End Sub