Salut tout le monde,
j'ai besoin de ch'ti coup de main pour adapter ce code que j'ai trouvé dans
le forum (merci à son concepteur...). Les conditions sont les suivantes :
dans la cellule G3, un chifre de -4 à >1. Dans H3, un autre chiffre en
fonction de G3 et ainsi de suite jusqu'à G1000. Exprimé autrement, ça
donnerait quelque chose comme ça :
si G3:G1000 >1; H3:H1000=0
si G3:G1000 = 1; H3:H1000= 1
si G3:G1000 = 0; H3:H1000= 2
si G3:G1000 = -1; H3:H1000= 3
si G3:G1000 = -2; H3:H1000= 4
si G3:G1000 = -3; H3:H1000= 5
si G3:G1000 = -4; H3:H1000= 6
Comment l'adapter à ce code-là ??? Ou, si ce n'est pas possible, comment
faire ??
Private Sub Worksheet_Change(ByVal Target As Range)
Dim c As Range
If Not Intersect(Target.Cells, Range("A1:A10")) Is Nothing Then
For Each c In Target
Select Case c.Value
Case "1": c.Font.ColorIndex = 3: c.Interior.ColorIndex = 1
Case "2": c.Font.ColorIndex = 2: c.Interior.ColorIndex = 2
Case "3": c.Font.ColorIndex = 4: c.Interior.ColorIndex = 3
Case "4": c.Font.ColorIndex = 23: c.Interior.ColorIndex = 4
Case "5": c.Font.ColorIndex = 13: c.Interior.ColorIndex = 5
Case "6": c.Font.ColorIndex = 9: c.Interior.ColorIndex = 6
Case Else: c.Font.ColorIndex = xlAutomatic:
c.Interior.ColorIndex = xlNone
End Select
Next
End If
End Sub
Merci d'avance !
PS : je vais également le mettre dans le forum VBA... Il sera peut-être plus
approprié.
--
Céd / Lausanne
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
Elliac
Bonjour,
der = Range("g50000").End(xlUp).Row Range("h3:h" & der) = _ "=IF(RC[-1]>1,0,IF(RC[-1]<-4,"""",IF(RC[-1]<=0,ABS(RC[-1])+2,1)))"
Camille
"Congelator" wrote:
Salut tout le monde, j'ai besoin de ch'ti coup de main pour adapter ce code que j'ai trouvé dans le forum (merci à son concepteur...). Les conditions sont les suivantes : dans la cellule G3, un chifre de -4 à >1. Dans H3, un autre chiffre en fonction de G3 et ainsi de suite jusqu'à G1000. Exprimé autrement, ça donnerait quelque chose comme ça : si G3:G1000 >1; H3:H1000=0 si G3:G1000 = 1; H3:H1000= 1 si G3:G1000 = 0; H3:H1000= 2 si G3:G1000 = -1; H3:H1000= 3 si G3:G1000 = -2; H3:H1000= 4 si G3:G1000 = -3; H3:H1000= 5 si G3:G1000 = -4; H3:H1000= 6
Comment l'adapter à ce code-là ??? Ou, si ce n'est pas possible, comment faire ??
Private Sub Worksheet_Change(ByVal Target As Range) Dim c As Range If Not Intersect(Target.Cells, Range("A1:A10")) Is Nothing Then For Each c In Target Select Case c.Value Case "1": c.Font.ColorIndex = 3: c.Interior.ColorIndex = 1 Case "2": c.Font.ColorIndex = 2: c.Interior.ColorIndex = 2 Case "3": c.Font.ColorIndex = 4: c.Interior.ColorIndex = 3 Case "4": c.Font.ColorIndex = 23: c.Interior.ColorIndex = 4 Case "5": c.Font.ColorIndex = 13: c.Interior.ColorIndex = 5 Case "6": c.Font.ColorIndex = 9: c.Interior.ColorIndex = 6 Case Else: c.Font.ColorIndex = xlAutomatic: c.Interior.ColorIndex = xlNone End Select Next End If End Sub
Merci d'avance !
PS : je vais également le mettre dans le forum VBA... Il sera peut-être plus approprié. -- Céd / Lausanne
Bonjour,
der = Range("g50000").End(xlUp).Row
Range("h3:h" & der) = _
"=IF(RC[-1]>1,0,IF(RC[-1]<-4,"""",IF(RC[-1]<=0,ABS(RC[-1])+2,1)))"
Camille
"Congelator" wrote:
Salut tout le monde,
j'ai besoin de ch'ti coup de main pour adapter ce code que j'ai trouvé dans
le forum (merci à son concepteur...). Les conditions sont les suivantes :
dans la cellule G3, un chifre de -4 à >1. Dans H3, un autre chiffre en
fonction de G3 et ainsi de suite jusqu'à G1000. Exprimé autrement, ça
donnerait quelque chose comme ça :
si G3:G1000 >1; H3:H1000=0
si G3:G1000 = 1; H3:H1000= 1
si G3:G1000 = 0; H3:H1000= 2
si G3:G1000 = -1; H3:H1000= 3
si G3:G1000 = -2; H3:H1000= 4
si G3:G1000 = -3; H3:H1000= 5
si G3:G1000 = -4; H3:H1000= 6
Comment l'adapter à ce code-là ??? Ou, si ce n'est pas possible, comment
faire ??
Private Sub Worksheet_Change(ByVal Target As Range)
Dim c As Range
If Not Intersect(Target.Cells, Range("A1:A10")) Is Nothing Then
For Each c In Target
Select Case c.Value
Case "1": c.Font.ColorIndex = 3: c.Interior.ColorIndex = 1
Case "2": c.Font.ColorIndex = 2: c.Interior.ColorIndex = 2
Case "3": c.Font.ColorIndex = 4: c.Interior.ColorIndex = 3
Case "4": c.Font.ColorIndex = 23: c.Interior.ColorIndex = 4
Case "5": c.Font.ColorIndex = 13: c.Interior.ColorIndex = 5
Case "6": c.Font.ColorIndex = 9: c.Interior.ColorIndex = 6
Case Else: c.Font.ColorIndex = xlAutomatic:
c.Interior.ColorIndex = xlNone
End Select
Next
End If
End Sub
Merci d'avance !
PS : je vais également le mettre dans le forum VBA... Il sera peut-être plus
approprié.
--
Céd / Lausanne
der = Range("g50000").End(xlUp).Row Range("h3:h" & der) = _ "=IF(RC[-1]>1,0,IF(RC[-1]<-4,"""",IF(RC[-1]<=0,ABS(RC[-1])+2,1)))"
Camille
"Congelator" wrote:
Salut tout le monde, j'ai besoin de ch'ti coup de main pour adapter ce code que j'ai trouvé dans le forum (merci à son concepteur...). Les conditions sont les suivantes : dans la cellule G3, un chifre de -4 à >1. Dans H3, un autre chiffre en fonction de G3 et ainsi de suite jusqu'à G1000. Exprimé autrement, ça donnerait quelque chose comme ça : si G3:G1000 >1; H3:H1000=0 si G3:G1000 = 1; H3:H1000= 1 si G3:G1000 = 0; H3:H1000= 2 si G3:G1000 = -1; H3:H1000= 3 si G3:G1000 = -2; H3:H1000= 4 si G3:G1000 = -3; H3:H1000= 5 si G3:G1000 = -4; H3:H1000= 6
Comment l'adapter à ce code-là ??? Ou, si ce n'est pas possible, comment faire ??
Private Sub Worksheet_Change(ByVal Target As Range) Dim c As Range If Not Intersect(Target.Cells, Range("A1:A10")) Is Nothing Then For Each c In Target Select Case c.Value Case "1": c.Font.ColorIndex = 3: c.Interior.ColorIndex = 1 Case "2": c.Font.ColorIndex = 2: c.Interior.ColorIndex = 2 Case "3": c.Font.ColorIndex = 4: c.Interior.ColorIndex = 3 Case "4": c.Font.ColorIndex = 23: c.Interior.ColorIndex = 4 Case "5": c.Font.ColorIndex = 13: c.Interior.ColorIndex = 5 Case "6": c.Font.ColorIndex = 9: c.Interior.ColorIndex = 6 Case Else: c.Font.ColorIndex = xlAutomatic: c.Interior.ColorIndex = xlNone End Select Next End If End Sub
Merci d'avance !
PS : je vais également le mettre dans le forum VBA... Il sera peut-être plus approprié. -- Céd / Lausanne
Congelator
Salut Camille,
Merci pour le coup de main mais ça ne fonctionne pas, en tout cas chez moi. Je pense que cela vient du code dans lequel j'ai inséré tes lignes.
Voilà comment je l'ai inséré.. où est l'erreur ?
Private Sub Worksheet_Change(ByVal Target As Range) der = Range("g50000").End(xlUp).Row Range("h3:h" & der) = _ "=IF(RC[-1]>1,0,IF(RC[-1]<-4,"""",IF(RC[-1]<=0,ABS(RC[-1])+2,1)))" End Sub
merci de ton aide -- Céd / Lausanne
Bonjour,
der = Range("g50000").End(xlUp).Row Range("h3:h" & der) = _ "=IF(RC[-1]>1,0,IF(RC[-1]<-4,"""",IF(RC[-1]<=0,ABS(RC[-1])+2,1)))"
Camille
"Congelator" wrote:
Salut tout le monde, j'ai besoin de ch'ti coup de main pour adapter ce code que j'ai trouvé dans le forum (merci à son concepteur...). Les conditions sont les suivantes : dans la cellule G3, un chifre de -4 à >1. Dans H3, un autre chiffre en fonction de G3 et ainsi de suite jusqu'à G1000. Exprimé autrement, ça donnerait quelque chose comme ça : si G3:G1000 >1; H3:H1000=0 si G3:G1000 = 1; H3:H1000= 1 si G3:G1000 = 0; H3:H1000= 2 si G3:G1000 = -1; H3:H1000= 3 si G3:G1000 = -2; H3:H1000= 4 si G3:G1000 = -3; H3:H1000= 5 si G3:G1000 = -4; H3:H1000= 6
Comment l'adapter à ce code-là ??? Ou, si ce n'est pas possible, comment faire ??
Private Sub Worksheet_Change(ByVal Target As Range) Dim c As Range If Not Intersect(Target.Cells, Range("A1:A10")) Is Nothing Then For Each c In Target Select Case c.Value Case "1": c.Font.ColorIndex = 3: c.Interior.ColorIndex = 1 Case "2": c.Font.ColorIndex = 2: c.Interior.ColorIndex = 2 Case "3": c.Font.ColorIndex = 4: c.Interior.ColorIndex = 3 Case "4": c.Font.ColorIndex = 23: c.Interior.ColorIndex = 4 Case "5": c.Font.ColorIndex = 13: c.Interior.ColorIndex = 5 Case "6": c.Font.ColorIndex = 9: c.Interior.ColorIndex = 6 Case Else: c.Font.ColorIndex = xlAutomatic: c.Interior.ColorIndex = xlNone End Select Next End If End Sub
Merci d'avance !
PS : je vais également le mettre dans le forum VBA... Il sera peut-être plus approprié. -- Céd / Lausanne
Salut Camille,
Merci pour le coup de main mais ça ne fonctionne pas, en tout cas chez moi.
Je pense que cela vient du code dans lequel j'ai inséré tes lignes.
Voilà comment je l'ai inséré.. où est l'erreur ?
Private Sub Worksheet_Change(ByVal Target As Range)
der = Range("g50000").End(xlUp).Row
Range("h3:h" & der) = _
"=IF(RC[-1]>1,0,IF(RC[-1]<-4,"""",IF(RC[-1]<=0,ABS(RC[-1])+2,1)))"
End Sub
merci de ton aide
--
Céd / Lausanne
Bonjour,
der = Range("g50000").End(xlUp).Row
Range("h3:h" & der) = _
"=IF(RC[-1]>1,0,IF(RC[-1]<-4,"""",IF(RC[-1]<=0,ABS(RC[-1])+2,1)))"
Camille
"Congelator" wrote:
Salut tout le monde,
j'ai besoin de ch'ti coup de main pour adapter ce code que j'ai trouvé dans
le forum (merci à son concepteur...). Les conditions sont les suivantes :
dans la cellule G3, un chifre de -4 à >1. Dans H3, un autre chiffre en
fonction de G3 et ainsi de suite jusqu'à G1000. Exprimé autrement, ça
donnerait quelque chose comme ça :
si G3:G1000 >1; H3:H1000=0
si G3:G1000 = 1; H3:H1000= 1
si G3:G1000 = 0; H3:H1000= 2
si G3:G1000 = -1; H3:H1000= 3
si G3:G1000 = -2; H3:H1000= 4
si G3:G1000 = -3; H3:H1000= 5
si G3:G1000 = -4; H3:H1000= 6
Comment l'adapter à ce code-là ??? Ou, si ce n'est pas possible, comment
faire ??
Private Sub Worksheet_Change(ByVal Target As Range)
Dim c As Range
If Not Intersect(Target.Cells, Range("A1:A10")) Is Nothing Then
For Each c In Target
Select Case c.Value
Case "1": c.Font.ColorIndex = 3: c.Interior.ColorIndex = 1
Case "2": c.Font.ColorIndex = 2: c.Interior.ColorIndex = 2
Case "3": c.Font.ColorIndex = 4: c.Interior.ColorIndex = 3
Case "4": c.Font.ColorIndex = 23: c.Interior.ColorIndex = 4
Case "5": c.Font.ColorIndex = 13: c.Interior.ColorIndex = 5
Case "6": c.Font.ColorIndex = 9: c.Interior.ColorIndex = 6
Case Else: c.Font.ColorIndex = xlAutomatic:
c.Interior.ColorIndex = xlNone
End Select
Next
End If
End Sub
Merci d'avance !
PS : je vais également le mettre dans le forum VBA... Il sera peut-être plus
approprié.
--
Céd / Lausanne
Merci pour le coup de main mais ça ne fonctionne pas, en tout cas chez moi. Je pense que cela vient du code dans lequel j'ai inséré tes lignes.
Voilà comment je l'ai inséré.. où est l'erreur ?
Private Sub Worksheet_Change(ByVal Target As Range) der = Range("g50000").End(xlUp).Row Range("h3:h" & der) = _ "=IF(RC[-1]>1,0,IF(RC[-1]<-4,"""",IF(RC[-1]<=0,ABS(RC[-1])+2,1)))" End Sub
merci de ton aide -- Céd / Lausanne
Bonjour,
der = Range("g50000").End(xlUp).Row Range("h3:h" & der) = _ "=IF(RC[-1]>1,0,IF(RC[-1]<-4,"""",IF(RC[-1]<=0,ABS(RC[-1])+2,1)))"
Camille
"Congelator" wrote:
Salut tout le monde, j'ai besoin de ch'ti coup de main pour adapter ce code que j'ai trouvé dans le forum (merci à son concepteur...). Les conditions sont les suivantes : dans la cellule G3, un chifre de -4 à >1. Dans H3, un autre chiffre en fonction de G3 et ainsi de suite jusqu'à G1000. Exprimé autrement, ça donnerait quelque chose comme ça : si G3:G1000 >1; H3:H1000=0 si G3:G1000 = 1; H3:H1000= 1 si G3:G1000 = 0; H3:H1000= 2 si G3:G1000 = -1; H3:H1000= 3 si G3:G1000 = -2; H3:H1000= 4 si G3:G1000 = -3; H3:H1000= 5 si G3:G1000 = -4; H3:H1000= 6
Comment l'adapter à ce code-là ??? Ou, si ce n'est pas possible, comment faire ??
Private Sub Worksheet_Change(ByVal Target As Range) Dim c As Range If Not Intersect(Target.Cells, Range("A1:A10")) Is Nothing Then For Each c In Target Select Case c.Value Case "1": c.Font.ColorIndex = 3: c.Interior.ColorIndex = 1 Case "2": c.Font.ColorIndex = 2: c.Interior.ColorIndex = 2 Case "3": c.Font.ColorIndex = 4: c.Interior.ColorIndex = 3 Case "4": c.Font.ColorIndex = 23: c.Interior.ColorIndex = 4 Case "5": c.Font.ColorIndex = 13: c.Interior.ColorIndex = 5 Case "6": c.Font.ColorIndex = 9: c.Interior.ColorIndex = 6 Case Else: c.Font.ColorIndex = xlAutomatic: c.Interior.ColorIndex = xlNone End Select Next End If End Sub
Merci d'avance !
PS : je vais également le mettre dans le forum VBA... Il sera peut-être plus approprié. -- Céd / Lausanne
Congelator
Salut Camille,
JT m'a founi LA solution... alors la voici pour ceux que ça intéressesait. Merci quand même pour ton aide.
B1 = Km déjà parcourus (deja) B2 = Km du mois (km) B3 = total b1+b2
der = Range("g50000").End(xlUp).Row Range("h3:h" & der) = _ "=IF(RC[-1]>1,0,IF(RC[-1]<-4,"""",IF(RC[-1]<=0,ABS(RC[-1])+2,1)))"
Camille
"Congelator" wrote:
Salut tout le monde, j'ai besoin de ch'ti coup de main pour adapter ce code que j'ai trouvé dans le forum (merci à son concepteur...). Les conditions sont les suivantes : dans la cellule G3, un chifre de -4 à >1. Dans H3, un autre chiffre en fonction de G3 et ainsi de suite jusqu'à G1000. Exprimé autrement, ça donnerait quelque chose comme ça : si G3:G1000 >1; H3:H1000=0 si G3:G1000 = 1; H3:H1000= 1 si G3:G1000 = 0; H3:H1000= 2 si G3:G1000 = -1; H3:H1000= 3 si G3:G1000 = -2; H3:H1000= 4 si G3:G1000 = -3; H3:H1000= 5 si G3:G1000 = -4; H3:H1000= 6
Comment l'adapter à ce code-là ??? Ou, si ce n'est pas possible, comment faire ??
Private Sub Worksheet_Change(ByVal Target As Range) Dim c As Range If Not Intersect(Target.Cells, Range("A1:A10")) Is Nothing Then For Each c In Target Select Case c.Value Case "1": c.Font.ColorIndex = 3: c.Interior.ColorIndex = 1 Case "2": c.Font.ColorIndex = 2: c.Interior.ColorIndex = 2 Case "3": c.Font.ColorIndex = 4: c.Interior.ColorIndex = 3 Case "4": c.Font.ColorIndex = 23: c.Interior.ColorIndex = 4 Case "5": c.Font.ColorIndex = 13: c.Interior.ColorIndex = 5 Case "6": c.Font.ColorIndex = 9: c.Interior.ColorIndex = 6 Case Else: c.Font.ColorIndex = xlAutomatic: c.Interior.ColorIndex = xlNone End Select Next End If End Sub
Merci d'avance !
PS : je vais également le mettre dans le forum VBA... Il sera peut-être plus approprié. -- Céd / Lausanne
Salut Camille,
JT m'a founi LA solution... alors la voici pour ceux que ça intéressesait.
Merci quand même pour ton aide.
B1 = Km déjà parcourus (deja)
B2 = Km du mois (km)
B3 = total b1+b2
der = Range("g50000").End(xlUp).Row
Range("h3:h" & der) = _
"=IF(RC[-1]>1,0,IF(RC[-1]<-4,"""",IF(RC[-1]<=0,ABS(RC[-1])+2,1)))"
Camille
"Congelator" wrote:
Salut tout le monde,
j'ai besoin de ch'ti coup de main pour adapter ce code que j'ai trouvé dans
le forum (merci à son concepteur...). Les conditions sont les suivantes :
dans la cellule G3, un chifre de -4 à >1. Dans H3, un autre chiffre en
fonction de G3 et ainsi de suite jusqu'à G1000. Exprimé autrement, ça
donnerait quelque chose comme ça :
si G3:G1000 >1; H3:H1000=0
si G3:G1000 = 1; H3:H1000= 1
si G3:G1000 = 0; H3:H1000= 2
si G3:G1000 = -1; H3:H1000= 3
si G3:G1000 = -2; H3:H1000= 4
si G3:G1000 = -3; H3:H1000= 5
si G3:G1000 = -4; H3:H1000= 6
Comment l'adapter à ce code-là ??? Ou, si ce n'est pas possible, comment
faire ??
Private Sub Worksheet_Change(ByVal Target As Range)
Dim c As Range
If Not Intersect(Target.Cells, Range("A1:A10")) Is Nothing Then
For Each c In Target
Select Case c.Value
Case "1": c.Font.ColorIndex = 3: c.Interior.ColorIndex = 1
Case "2": c.Font.ColorIndex = 2: c.Interior.ColorIndex = 2
Case "3": c.Font.ColorIndex = 4: c.Interior.ColorIndex = 3
Case "4": c.Font.ColorIndex = 23: c.Interior.ColorIndex = 4
Case "5": c.Font.ColorIndex = 13: c.Interior.ColorIndex = 5
Case "6": c.Font.ColorIndex = 9: c.Interior.ColorIndex = 6
Case Else: c.Font.ColorIndex = xlAutomatic:
c.Interior.ColorIndex = xlNone
End Select
Next
End If
End Sub
Merci d'avance !
PS : je vais également le mettre dans le forum VBA... Il sera peut-être plus
approprié.
--
Céd / Lausanne
der = Range("g50000").End(xlUp).Row Range("h3:h" & der) = _ "=IF(RC[-1]>1,0,IF(RC[-1]<-4,"""",IF(RC[-1]<=0,ABS(RC[-1])+2,1)))"
Camille
"Congelator" wrote:
Salut tout le monde, j'ai besoin de ch'ti coup de main pour adapter ce code que j'ai trouvé dans le forum (merci à son concepteur...). Les conditions sont les suivantes : dans la cellule G3, un chifre de -4 à >1. Dans H3, un autre chiffre en fonction de G3 et ainsi de suite jusqu'à G1000. Exprimé autrement, ça donnerait quelque chose comme ça : si G3:G1000 >1; H3:H1000=0 si G3:G1000 = 1; H3:H1000= 1 si G3:G1000 = 0; H3:H1000= 2 si G3:G1000 = -1; H3:H1000= 3 si G3:G1000 = -2; H3:H1000= 4 si G3:G1000 = -3; H3:H1000= 5 si G3:G1000 = -4; H3:H1000= 6
Comment l'adapter à ce code-là ??? Ou, si ce n'est pas possible, comment faire ??
Private Sub Worksheet_Change(ByVal Target As Range) Dim c As Range If Not Intersect(Target.Cells, Range("A1:A10")) Is Nothing Then For Each c In Target Select Case c.Value Case "1": c.Font.ColorIndex = 3: c.Interior.ColorIndex = 1 Case "2": c.Font.ColorIndex = 2: c.Interior.ColorIndex = 2 Case "3": c.Font.ColorIndex = 4: c.Interior.ColorIndex = 3 Case "4": c.Font.ColorIndex = 23: c.Interior.ColorIndex = 4 Case "5": c.Font.ColorIndex = 13: c.Interior.ColorIndex = 5 Case "6": c.Font.ColorIndex = 9: c.Interior.ColorIndex = 6 Case Else: c.Font.ColorIndex = xlAutomatic: c.Interior.ColorIndex = xlNone End Select Next End If End Sub
Merci d'avance !
PS : je vais également le mettre dans le forum VBA... Il sera peut-être plus approprié. -- Céd / Lausanne
Congelator
Salut Camille,
J'ai trouvé la solution. C'était tout simple mais je croyais qu'on était limité à 6 conditions mais c'est 7... alors tout baigne. Pour info, voila comment j'ai remédié à ça.
der = Range("g50000").End(xlUp).Row Range("h3:h" & der) = _ "=IF(RC[-1]>1,0,IF(RC[-1]<-4,"""",IF(RC[-1]<=0,ABS(RC[-1])+2,1)))"
Camille
"Congelator" wrote:
Salut tout le monde, j'ai besoin de ch'ti coup de main pour adapter ce code que j'ai trouvé dans le forum (merci à son concepteur...). Les conditions sont les suivantes : dans la cellule G3, un chifre de -4 à >1. Dans H3, un autre chiffre en fonction de G3 et ainsi de suite jusqu'à G1000. Exprimé autrement, ça donnerait quelque chose comme ça : si G3:G1000 >1; H3:H1000=0 si G3:G1000 = 1; H3:H1000= 1 si G3:G1000 = 0; H3:H1000= 2 si G3:G1000 = -1; H3:H1000= 3 si G3:G1000 = -2; H3:H1000= 4 si G3:G1000 = -3; H3:H1000= 5 si G3:G1000 = -4; H3:H1000= 6
Comment l'adapter à ce code-là ??? Ou, si ce n'est pas possible, comment faire ??
Private Sub Worksheet_Change(ByVal Target As Range) Dim c As Range If Not Intersect(Target.Cells, Range("A1:A10")) Is Nothing Then For Each c In Target Select Case c.Value Case "1": c.Font.ColorIndex = 3: c.Interior.ColorIndex = 1 Case "2": c.Font.ColorIndex = 2: c.Interior.ColorIndex = 2 Case "3": c.Font.ColorIndex = 4: c.Interior.ColorIndex = 3 Case "4": c.Font.ColorIndex = 23: c.Interior.ColorIndex = 4 Case "5": c.Font.ColorIndex = 13: c.Interior.ColorIndex = 5 Case "6": c.Font.ColorIndex = 9: c.Interior.ColorIndex = 6 Case Else: c.Font.ColorIndex = xlAutomatic: c.Interior.ColorIndex = xlNone End Select Next End If End Sub
Merci d'avance !
PS : je vais également le mettre dans le forum VBA... Il sera peut-être plus approprié. -- Céd / Lausanne
Salut Camille,
J'ai trouvé la solution. C'était tout simple mais je croyais qu'on était
limité à 6 conditions mais c'est 7... alors tout baigne. Pour info, voila
comment j'ai remédié à ça.
der = Range("g50000").End(xlUp).Row
Range("h3:h" & der) = _
"=IF(RC[-1]>1,0,IF(RC[-1]<-4,"""",IF(RC[-1]<=0,ABS(RC[-1])+2,1)))"
Camille
"Congelator" wrote:
Salut tout le monde,
j'ai besoin de ch'ti coup de main pour adapter ce code que j'ai trouvé dans
le forum (merci à son concepteur...). Les conditions sont les suivantes :
dans la cellule G3, un chifre de -4 à >1. Dans H3, un autre chiffre en
fonction de G3 et ainsi de suite jusqu'à G1000. Exprimé autrement, ça
donnerait quelque chose comme ça :
si G3:G1000 >1; H3:H1000=0
si G3:G1000 = 1; H3:H1000= 1
si G3:G1000 = 0; H3:H1000= 2
si G3:G1000 = -1; H3:H1000= 3
si G3:G1000 = -2; H3:H1000= 4
si G3:G1000 = -3; H3:H1000= 5
si G3:G1000 = -4; H3:H1000= 6
Comment l'adapter à ce code-là ??? Ou, si ce n'est pas possible, comment
faire ??
Private Sub Worksheet_Change(ByVal Target As Range)
Dim c As Range
If Not Intersect(Target.Cells, Range("A1:A10")) Is Nothing Then
For Each c In Target
Select Case c.Value
Case "1": c.Font.ColorIndex = 3: c.Interior.ColorIndex = 1
Case "2": c.Font.ColorIndex = 2: c.Interior.ColorIndex = 2
Case "3": c.Font.ColorIndex = 4: c.Interior.ColorIndex = 3
Case "4": c.Font.ColorIndex = 23: c.Interior.ColorIndex = 4
Case "5": c.Font.ColorIndex = 13: c.Interior.ColorIndex = 5
Case "6": c.Font.ColorIndex = 9: c.Interior.ColorIndex = 6
Case Else: c.Font.ColorIndex = xlAutomatic:
c.Interior.ColorIndex = xlNone
End Select
Next
End If
End Sub
Merci d'avance !
PS : je vais également le mettre dans le forum VBA... Il sera peut-être plus
approprié.
--
Céd / Lausanne
J'ai trouvé la solution. C'était tout simple mais je croyais qu'on était limité à 6 conditions mais c'est 7... alors tout baigne. Pour info, voila comment j'ai remédié à ça.
der = Range("g50000").End(xlUp).Row Range("h3:h" & der) = _ "=IF(RC[-1]>1,0,IF(RC[-1]<-4,"""",IF(RC[-1]<=0,ABS(RC[-1])+2,1)))"
Camille
"Congelator" wrote:
Salut tout le monde, j'ai besoin de ch'ti coup de main pour adapter ce code que j'ai trouvé dans le forum (merci à son concepteur...). Les conditions sont les suivantes : dans la cellule G3, un chifre de -4 à >1. Dans H3, un autre chiffre en fonction de G3 et ainsi de suite jusqu'à G1000. Exprimé autrement, ça donnerait quelque chose comme ça : si G3:G1000 >1; H3:H1000=0 si G3:G1000 = 1; H3:H1000= 1 si G3:G1000 = 0; H3:H1000= 2 si G3:G1000 = -1; H3:H1000= 3 si G3:G1000 = -2; H3:H1000= 4 si G3:G1000 = -3; H3:H1000= 5 si G3:G1000 = -4; H3:H1000= 6
Comment l'adapter à ce code-là ??? Ou, si ce n'est pas possible, comment faire ??
Private Sub Worksheet_Change(ByVal Target As Range) Dim c As Range If Not Intersect(Target.Cells, Range("A1:A10")) Is Nothing Then For Each c In Target Select Case c.Value Case "1": c.Font.ColorIndex = 3: c.Interior.ColorIndex = 1 Case "2": c.Font.ColorIndex = 2: c.Interior.ColorIndex = 2 Case "3": c.Font.ColorIndex = 4: c.Interior.ColorIndex = 3 Case "4": c.Font.ColorIndex = 23: c.Interior.ColorIndex = 4 Case "5": c.Font.ColorIndex = 13: c.Interior.ColorIndex = 5 Case "6": c.Font.ColorIndex = 9: c.Interior.ColorIndex = 6 Case Else: c.Font.ColorIndex = xlAutomatic: c.Interior.ColorIndex = xlNone End Select Next End If End Sub
Merci d'avance !
PS : je vais également le mettre dans le forum VBA... Il sera peut-être plus approprié. -- Céd / Lausanne