De la couleur!

  • Initiateur de la discussion Alex
  • Date de début
A

Alex

Guest
Bonjour,

J'ai une nouvelle question concernant les couleurs de cellules. J'avais déjà posé cette question mais mon programme a été modifié.Voila ma procédure:

Sub tab1(coche As Boolean, cellule As Range, texte As String, Optional couleur As Range, Optional lignes As Range, Optional efface As Range)

On Error Resume Next
If coche = True Then
cellule = texte
couleur.Interior.ColorIndex = 6
lignes.Hidden = False
Else
efface = ""
lignes.Hidden = True
cellule = ""
couleur.Interior.ColorIndex = xlNone
End If

End Sub


Private Sub CommandButton1_Click()
tab1 CheckBox1.Value, Range("c37"), CheckBox1.Caption, Range("e6,e7,e8,e31"), Rows("36:42"), Range("i42")
tab1 CheckBox2.Value, Range("c44"), CheckBox2.Caption, Range("e7,e8,e9,e31"), Rows("43:48"), Range("i48")
tab1 CheckBox3.Value, Range("c50"), CheckBox3.Caption, , Rows("49:54"), Range("i54")
tab1 CheckBox4.Value, Range("c56"), CheckBox4.Caption, Range("e10,e11,e31"), Rows("55:59"), Range("i59")
tab1 CheckBox5.Value, Range("c61"), CheckBox5.Caption, , Rows("60:66"), Range("i66")
tab1 CheckBox6.Value, Range("c68"), CheckBox6.Caption, , Rows("67:71"), Range("i71")
tab1 CheckBox7.Value, Range("c73"), CheckBox7.Caption, Range("e12,e13,e14,e15,e16,e31"), Rows("72:79"), Range("i79")
tab1 CheckBox8.Value, Range("c81"), CheckBox8.Caption, Range("e23,e24,e25,e26,e31"), Rows("80:87"), Range("i87")
tab1 CheckBox9.Value, Range("c89"), CheckBox9.Caption, Range("e19,e22,e31"), Rows("88:91"), Range("i91")
tab1 CheckBox10.Value, Range("c93"), CheckBox10.Caption, Range("e17,e18,e20,e21,e31"), Rows("92:98"), Range("i98")
tab1 CheckBox11.Value, Range("c100"), CheckBox11.Caption, Range("e27"), Rows("99:102"), Range("i102")
tab1 CheckBox12.Value, Range("c104"), CheckBox12.Caption, Range("e6,e28"), Rows("103:106"), Range("i106")
tab1 CheckBox13.Value, Range("c108"), CheckBox13.Caption, , Rows("107:113"), Range("i113")

Unload Me
Hypothèses2.Show

End Sub

Si je clique seulement sur mes deux premières checkboxs, je devrais avoir en jaune, les cellules e6, e7,e8, e9, et e31.Or je n'ai que la e7, e8 et e9. Je suppose que le fait de ne pas cliquer les autres checkboxs annulent les deux premières. Que dois-je changer dans men programme?

Merci beaucoup pour votre aide
 
P

Popeye

Guest
Bonjour
dans ton code

tu mets que si la checkbox est pas cochée il faut enlever la couleur
regarde bien
si checkbox 1=true et checkbox12=false
avec checkbox12 tu efface la couleur de e6
pour e31 c a cause du checkbox 7 8 9 ou 10(ta le choix ;o))
 
P

Popeye

Guest
hum

moi je dirai ca


Sub tab1(coche As Boolean, cellule As Range, texte As String, Optional couleur As Range, Optional lignes As Range, Optional efface As Range)

On Error Resume Next
If coche = True Then
cellule = texte
couleur.Interior.ColorIndex = 6
lignes.Hidden = False
End If

End Sub

Sub tab2(coche As Boolean, cellule As Range, texte As String, Optional couleur As Range, Optional lignes As Range, Optional efface As Range)

On Error Resume Next
If coche = false Then
efface = ""
lignes.Hidden = True
cellule = ""
couleur.Interior.ColorIndex = xlNone
End If

End Sub


Private Sub CommandButton1_Click()
'############
tab2 CheckBox1.Value, Range("c37"), CheckBox1.Caption, Range("e6,e7,e8,e31"), Rows("36:42"), Range("i42")
tab2 CheckBox2.Value, Range("c44"), CheckBox2.Caption, Range("e7,e8,e9,e31"), Rows("43:48"), Range("i48")
tab2 CheckBox3.Value, Range("c50"), CheckBox3.Caption, , Rows("49:54"), Range("i54")
tab2 CheckBox4.Value, Range("c56"), CheckBox4.Caption, Range("e10,e11,e31"), Rows("55:59"), Range("i59")
tab2 CheckBox5.Value, Range("c61"), CheckBox5.Caption, , Rows("60:66"), Range("i66")
tab2 CheckBox6.Value, Range("c68"), CheckBox6.Caption, , Rows("67:71"), Range("i71")
tab2 CheckBox7.Value, Range("c73"), CheckBox7.Caption, Range("e12,e13,e14,e15,e16,e31"), Rows("72:79"), Range("i79")
tab2 CheckBox8.Value, Range("c81"), CheckBox8.Caption, Range("e23,e24,e25,e26,e31"), Rows("80:87"), Range("i87")
tab2 CheckBox9.Value, Range("c89"), CheckBox9.Caption, Range("e19,e22,e31"), Rows("88:91"), Range("i91")
tab2 CheckBox10.Value, Range("c93"), CheckBox10.Caption, Range("e17,e18,e20,e21,e31"), Rows("92:98"), Range("i98")
tab2 CheckBox11.Value, Range("c100"), CheckBox11.Caption, Range("e27"), Rows("99:102"), Range("i102")
tab2 CheckBox12.Value, Range("c104"), CheckBox12.Caption, Range("e6,e28"), Rows("103:106"), Range("i106")
tab2 CheckBox13.Value, Range("c108"), CheckBox13.Caption, , Rows("107:113"), Range("i113")
'##################
tab1 CheckBox1.Value, Range("c37"), CheckBox1.Caption, Range("e6,e7,e8,e31"), Rows("36:42"), Range("i42")
tab1 CheckBox2.Value, Range("c44"), CheckBox2.Caption, Range("e7,e8,e9,e31"), Rows("43:48"), Range("i48")
tab1 CheckBox3.Value, Range("c50"), CheckBox3.Caption, , Rows("49:54"), Range("i54")
tab1 CheckBox4.Value, Range("c56"), CheckBox4.Caption, Range("e10,e11,e31"), Rows("55:59"), Range("i59")
tab1 CheckBox5.Value, Range("c61"), CheckBox5.Caption, , Rows("60:66"), Range("i66")
tab1 CheckBox6.Value, Range("c68"), CheckBox6.Caption, , Rows("67:71"), Range("i71")
tab1 CheckBox7.Value, Range("c73"), CheckBox7.Caption, Range("e12,e13,e14,e15,e16,e31"), Rows("72:79"), Range("i79")
tab1 CheckBox8.Value, Range("c81"), CheckBox8.Caption, Range("e23,e24,e25,e26,e31"), Rows("80:87"), Range("i87")
tab1 CheckBox9.Value, Range("c89"), CheckBox9.Caption, Range("e19,e22,e31"), Rows("88:91"), Range("i91")
tab1 CheckBox10.Value, Range("c93"), CheckBox10.Caption, Range("e17,e18,e20,e21,e31"), Rows("92:98"), Range("i98")
tab1 CheckBox11.Value, Range("c100"), CheckBox11.Caption, Range("e27"), Rows("99:102"), Range("i102")
tab1 CheckBox12.Value, Range("c104"), CheckBox12.Caption, Range("e6,e28"), Rows("103:106"), Range("i106")
tab1 CheckBox13.Value, Range("c108"), CheckBox13.Caption, , Rows("107:113"), Range("i113")

Unload Me
Hypothèses2.Show

End Sub




c plus lourd mais ca devrait marcher je pense car tu visionne d'abord ce qui n'ont pas de couleur et apres tu met la couleur (le plus important non?)
 
A

Alex

Guest
Un grand merci Popeye, ça marche super bien.
Une simple question pour terminer:lorsque certaines lignes s'effacent, certaines bordures dans mon tableau sont coupées.C'est simplement un problème de mise en page, alors si t'as une idée, merci d'avance
 

Statistiques des forums

Discussions
312 330
Messages
2 087 335
Membres
103 521
dernier inscrit
Excellover 21