Boucle pour reduire le programme

Fermé
blalaa Messages postés 167 Date d'inscription mercredi 18 avril 2018 Statut Membre Dernière intervention 24 mars 2020 - 18 mars 2019 à 11:35
blalaa Messages postés 167 Date d'inscription mercredi 18 avril 2018 Statut Membre Dernière intervention 24 mars 2020 - 23 mars 2019 à 20:30
bonjour

j'ai mis un code qui vas afficher un chiffre en fonction de couleurs, mais le programe est tres long je me suis dis peut etre je peux le faire par une boucle comme ca je vais gagner du temps mais surtout de la place , sacjant que je nai pas encore finit

le principe :
jai 4 indicateur Q P D C
chaque indicateur doit prendre une couleur (rouge, noire , orange ou vert)
par exemample si tout les indicateur Q , P ,D,C Prendront la couleur rouge
ma cellule va m'afficher le chifre 1111
le 1 correspond a la couleur rouge
2 correspond la couleur noire
3 correspond a la couleur orange
4 correspond a la couleur vert
si l'indicateur Q prend la couleur noire et les autre prendront la couleur orange
ma cellule va mafficer le chifre 2333
ainsi de suit

donc pour faire tt les probabilité de couleur pour les indicateur il me faut vraiment un tres long programe

voici le code que jia mis pour linstant

ce code est valide si 3 indicateurs ont mm la couleurs et le 4 eme est different

il me reste encore d'autre probabilité



If VB_comments.TextBox2.BackColor = RGB(250, 100, 100) And VB_comments.TextBox3.BackColor = RGB(250, 100, 100) And VB_comments.TextBox4.BackColor = RGB(250, 100, 100) And VB_comments.TextBox5.BackColor = RGB(250, 100, 100) Then
ActiveCell.offset(0, 6).Value = 1111
'si tout les casez noir
ElseIf VB_comments.TextBox2.BackColor = RGB(0, 0, 0) And VB_comments.TextBox3.BackColor = RGB(0, 0, 0) And VB_comments.TextBox4.BackColor = RGB(0, 0, 0) And VB_comments.TextBox5.BackColor = RGB(0, 0, 0) Then
ActiveCell.offset(0, 6).Value = 2222
'toute les case orange
ElseIf VB_comments.TextBox2.BackColor = RGB(250, 175, 100) And VB_comments.TextBox3.BackColor = RGB(250, 175, 100) And VB_comments.TextBox4.BackColor = RGB(250, 175, 100) And VB_comments.TextBox5.BackColor = RGB(250, 175, 100) Then
ActiveCell.offset(0, 6).Value = 3333
'toute les cases vertes
ElseIf VB_comments.TextBox2.BackColor = RGB(175, 250, 175) And VB_comments.TextBox3.BackColor = RGB(175, 250, 175) And VB_comments.TextBox4.BackColor = RGB(175, 250, 175) And VB_comments.TextBox5.BackColor = RGB(175, 250, 175) Then
ActiveCell.offset(0, 6).Value = 4444

'Q noire les autres rouges
ElseIf VB_comments.TextBox2.BackColor = RGB(0, 0, 0) And VB_comments.TextBox3.BackColor = RGB(250, 100, 100) And VB_comments.TextBox4.BackColor = RGB(250, 100, 100) And VB_comments.TextBox5.BackColor = RGB(250, 100, 100) Then
ActiveCell.offset(0, 6).Value = 2111

'Q orange les autres rouges
ElseIf VB_comments.TextBox2.BackColor = RGB(250, 175, 100) And VB_comments.TextBox3.BackColor = RGB(250, 100, 100) And VB_comments.TextBox4.BackColor = RGB(250, 100, 100) And VB_comments.TextBox5.BackColor = RGB(250, 100, 100) Then
ActiveCell.offset(0, 6).Value = 3111

'Q vert les autres rouges
ElseIf VB_comments.TextBox2.BackColor = RGB(175, 250, 175) And VB_comments.TextBox3.BackColor = RGB(250, 100, 100) And VB_comments.TextBox4.BackColor = RGB(250, 100, 100) And VB_comments.TextBox5.BackColor = RGB(250, 100, 100) Then
ActiveCell.offset(0, 6).Value = 4111

'fixer Q D C

'P est noire les autres rouge
ElseIf VB_comments.TextBox2.BackColor = RGB(250, 100, 100) And VB_comments.TextBox3.BackColor = RGB(0, 0, 0) And VB_comments.TextBox4.BackColor = RGB(250, 100, 100) And VB_comments.TextBox5.BackColor = RGB(250, 100, 100) Then
ActiveCell.offset(0, 6).Value = 1211

'P est orange les autres rouge
ElseIf VB_comments.TextBox2.BackColor = RGB(250, 100, 100) And VB_comments.TextBox3.BackColor = RGB(250, 175, 100) And VB_comments.TextBox4.BackColor = RGB(250, 100, 100) And VB_comments.TextBox5.BackColor = RGB(250, 100, 100) Then
ActiveCell.offset(0, 6).Value = 1311

'P est vert les autres rouge
ElseIf VB_comments.TextBox2.BackColor = RGB(250, 100, 100) And VB_comments.TextBox3.BackColor = RGB(175, 250, 175) And VB_comments.TextBox4.BackColor = RGB(250, 100, 100) And VB_comments.TextBox5.BackColor = RGB(250, 100, 100) Then
ActiveCell.offset(0, 6).Value = 1411

'fixer P Q C

'D est noire P Q C rouge
ElseIf VB_comments.TextBox2.BackColor = RGB(250, 100, 100) And VB_comments.TextBox3.BackColor = RGB(250, 100, 100) And VB_comments.TextBox4.BackColor = RGB(0, 0, 0) And VB_comments.TextBox5.BackColor = RGB(250, 100, 100) Then
ActiveCell.offset(0, 6).Value = 1121

'D est orange P Q C rouges
ElseIf VB_comments.TextBox2.BackColor = RGB(250, 100, 100) And VB_comments.TextBox3.BackColor = RGB(250, 100, 100) And VB_comments.TextBox4.BackColor = RGB(250, 175, 100) And VB_comments.TextBox5.BackColor = RGB(250, 100, 100) Then
ActiveCell.offset(0, 6).Value = 1131

'D est vert P Q C rouges
ElseIf VB_comments.TextBox2.BackColor = RGB(250, 100, 100) And VB_comments.TextBox3.BackColor = RGB(250, 100, 100) And VB_comments.TextBox4.BackColor = RGB(175, 250, 175) And VB_comments.TextBox5.BackColor = RGB(250, 100, 100) Then
ActiveCell.offset(0, 6).Value = 1141

'fixer Q P D

'C est noire Q P D rouges
ElseIf VB_comments.TextBox2.BackColor = RGB(250, 100, 100) And VB_comments.TextBox3.BackColor = RGB(250, 100, 100) And VB_comments.TextBox4.BackColor = RGB(250, 100, 100) And VB_comments.TextBox5.BackColor = RGB(0, 0, 0) Then
ActiveCell.offset(0, 6).Value = 1112

'C est orange Q P D rouges
ElseIf VB_comments.TextBox2.BackColor = RGB(250, 100, 100) And VB_comments.TextBox3.BackColor = RGB(250, 100, 100) And VB_comments.TextBox4.BackColor = RGB(250, 100, 100) And VB_comments.TextBox5.BackColor = RGB(250, 175, 100) Then
ActiveCell.offset(0, 6).Value = 1113

'C est vert Q P D rouges
ElseIf VB_comments.TextBox2.BackColor = RGB(250, 100, 100) And VB_comments.TextBox3.BackColor = RGB(250, 100, 100) And VB_comments.TextBox4.BackColor = RGB(250, 100, 100) And VB_comments.TextBox5.BackColor = RGB(175, 250, 175) Then
ActiveCell.offset(0, 6).Value = 1114
'___________________________________________________________________________________________________________________________

'Q noire les autres orange
ElseIf VB_comments.TextBox2.BackColor = RGB(0, 0, 0) And VB_comments.TextBox3.BackColor = RGB(250, 175, 100) And VB_comments.TextBox4.BackColor = RGB(250, 175, 100) And VB_comments.TextBox5.BackColor = RGB(250, 175, 100) Then
ActiveCell.offset(0, 6).Value = 2333


'Q vert les autres orange
ElseIf VB_comments.TextBox2.BackColor = RGB(250, 175, 100) And VB_comments.TextBox3.BackColor = RGB(250, 175, 100) And VB_comments.TextBox4.BackColor = RGB(250, 175, 100) And VB_comments.TextBox5.BackColor = RGB(250, 175, 100) Then
ActiveCell.offset(0, 6).Value = 4333

'Q rouge les autres orange
ElseIf VB_comments.TextBox2.BackColor = RGB(250, 100, 100) And VB_comments.TextBox3.BackColor = RGB(250, 175, 100) And VB_comments.TextBox4.BackColor = RGB(250, 175, 100) And VB_comments.TextBox5.BackColor = RGB(250, 175, 100) Then
ActiveCell.offset(0, 6).Value = 1333

'fixer Q D C

'P est noire les autres orange
ElseIf VB_comments.TextBox2.BackColor = RGB(250, 175, 100) And VB_comments.TextBox3.BackColor = RGB(0, 0, 0) And VB_comments.TextBox4.BackColor = RGB(250, 175, 100) And VB_comments.TextBox5.BackColor = RGB(250, 175, 100) Then
ActiveCell.offset(0, 6).Value = 3233

'P est rouge les autres orange
ElseIf VB_comments.TextBox2.BackColor = RGB(250, 175, 100) And VB_comments.TextBox3.BackColor = RGB(250, 100, 100) And VB_comments.TextBox4.BackColor = RGB(250, 175, 100) And VB_comments.TextBox5.BackColor = RGB(250, 175, 100) Then
ActiveCell.offset(0, 6).Value = 3133

'P est vert les autres orange
ElseIf VB_comments.TextBox2.BackColor = RGB(250, 175, 100) And VB_comments.TextBox3.BackColor = RGB(175, 250, 175) And VB_comments.TextBox4.BackColor = RGB(250, 175, 100) And VB_comments.TextBox5.BackColor = RGB(250, 175, 100) Then
ActiveCell.offset(0, 6).Value = 3433

'fixer P Q C

'D est noire P Q C orange
ElseIf VB_comments.TextBox2.BackColor = RGB(250, 175, 100) And VB_comments.TextBox3.BackColor = RGB(250, 175, 100) And VB_comments.TextBox4.BackColor = RGB(0, 0, 0) And VB_comments.TextBox5.BackColor = RGB(250, 175, 100) Then
ActiveCell.offset(0, 6).Value = 3323

'D est rouge P Q C orange
ElseIf VB_comments.TextBox2.BackColor = RGB(250, 175, 100) And VB_comments.TextBox3.BackColor = RGB(250, 175, 100) And VB_comments.TextBox4.BackColor = RGB(250, 100, 100) And VB_comments.TextBox5.BackColor = RGB(250, 175, 100) Then
ActiveCell.offset(0, 6).Value = 3313


'D est vert P Q C orange
ElseIf VB_comments.TextBox2.BackColor = RGB(250, 175, 100) And VB_comments.TextBox3.BackColor = RGB(250, 175, 100) And VB_comments.TextBox4.BackColor = RGB(175, 250, 175) And VB_comments.TextBox5.BackColor = RGB(250, 175, 100) Then
ActiveCell.offset(0, 6).Value = 3343

'fixer Q P D

'C est noire Q P D orange
ElseIf VB_comments.TextBox2.BackColor = RGB(250, 175, 100) And VB_comments.TextBox3.BackColor = RGB(250, 175, 100) And VB_comments.TextBox4.BackColor = RGB(250, 175, 100) And VB_comments.TextBox5.BackColor = RGB(0, 0, 0) Then
ActiveCell.offset(0, 6).Value = 3332

'C est rouge Q P D orange
ElseIf VB_comments.TextBox2.BackColor = RGB(250, 175, 100) And VB_comments.TextBox3.BackColor = RGB(250, 175, 100) And VB_comments.TextBox4.BackColor = RGB(250, 175, 100) And VB_comments.TextBox5.BackColor = RGB(250, 100, 100) Then
ActiveCell.offset(0, 6).Value = 3331


'C est vert Q P D orange
ElseIf VB_comments.TextBox2.BackColor = RGB(250, 175, 100) And VB_comments.TextBox3.BackColor = RGB(250, 175, 100) And VB_comments.TextBox4.BackColor = RGB(250, 175, 100) And VB_comments.TextBox5.BackColor = RGB(175, 250, 175) Then
ActiveCell.offset(0, 6).Value = 3334

'_________________________________________________________________________________________________________

'Q noire les autres vert
ElseIf VB_comments.TextBox2.BackColor = RGB(0, 0, 0) And VB_comments.TextBox3.BackColor = RGB(175, 250, 175) And VB_comments.TextBox4.BackColor = RGB(175, 250, 175) And VB_comments.TextBox5.BackColor = RGB(175, 250, 175) Then
ActiveCell.offset(0, 6).Value = 2444

'Q orange les autres vert
ElseIf VB_comments.TextBox2.BackColor = RGB(250, 175, 100) And VB_comments.TextBox3.BackColor = RGB(175, 250, 175) And VB_comments.TextBox4.BackColor = RGB(175, 250, 175) And VB_comments.TextBox5.BackColor = RGB(175, 250, 175) Then
ActiveCell.offset(0, 6).Value = 3444


'Q rouge les autres vert
ElseIf VB_comments.TextBox2.BackColor = RGB(250, 100, 100) And VB_comments.TextBox3.BackColor = RGB(175, 250, 175) And VB_comments.TextBox4.BackColor = RGB(175, 250, 175) And VB_comments.TextBox5.BackColor = RGB(175, 250, 175) Then
ActiveCell.offset(0, 6).Value = 1444

'fixer Q D C

'P est noire les autres vert
ElseIf VB_comments.TextBox2.BackColor = RGB(175, 250, 175) And VB_comments.TextBox3.BackColor = RGB(0, 0, 0) And VB_comments.TextBox4.BackColor = RGB(175, 250, 175) And VB_comments.TextBox5.BackColor = RGB(175, 250, 175) Then
ActiveCell.offset(0, 6).Value = 4244

'P est orange les autres vert
ElseIf VB_comments.TextBox2.BackColor = RGB(175, 250, 175) And VB_comments.TextBox3.BackColor = RGB(250, 175, 100) And VB_comments.TextBox4.BackColor = RGB(175, 250, 175) And VB_comments.TextBox5.BackColor = RGB(175, 250, 175) Then
ActiveCell.offset(0, 6).Value = 4344

'P est rouge les autres vert
ElseIf VB_comments.TextBox2.BackColor = RGB(175, 250, 175) And VB_comments.TextBox3.BackColor = RGB(250, 100, 100) And VB_comments.TextBox4.BackColor = RGB(175, 250, 175) And VB_comments.TextBox5.BackColor = RGB(175, 250, 175) Then
ActiveCell.offset(0, 6).Value = 4144


'fixer P Q C

'D est noire P Q C vert
ElseIf VB_comments.TextBox2.BackColor = RGB(175, 250, 175) And VB_comments.TextBox3.BackColor = RGB(175, 250, 175) And VB_comments.TextBox4.BackColor = RGB(0, 0, 0) And VB_comments.TextBox5.BackColor = RGB(175, 250, 175) Then
ActiveCell.offset(0, 6).Value = 4424

'D est orange P Q C vert
ElseIf VB_comments.TextBox2.BackColor = RGB(175, 250, 175) And VB_comments.TextBox3.BackColor = RGB(175, 250, 175) And VB_comments.TextBox4.BackColor = RGB(250, 175, 100) And VB_comments.TextBox5.BackColor = RGB(175, 250, 175) Then
ActiveCell.offset(0, 6).Value = 4434


'D est rouge P Q C vert
ElseIf VB_comments.TextBox2.BackColor = RGB(175, 250, 175) And VB_comments.TextBox3.BackColor = RGB(175, 250, 175) And VB_comments.TextBox4.BackColor = RGB(250, 100, 100) And VB_comments.TextBox5.BackColor = RGB(175, 250, 175) Then
ActiveCell.offset(0, 6).Value = 4414
'fixer Q P D

'C est noire Q P D vert
ElseIf VB_comments.TextBox2.BackColor = RGB(175, 250, 175) And VB_comments.TextBox3.BackColor = RGB(175, 250, 175) And VB_comments.TextBox4.BackColor = RGB(175, 250, 175) And VB_comments.TextBox5.BackColor = RGB(0, 0, 0) Then
ActiveCell.offset(0, 6).Value = 4442

'C est orange Q P D vert
ElseIf VB_comments.TextBox2.BackColor = RGB(175, 250, 175) And VB_comments.TextBox3.BackColor = RGB(175, 250, 175) And VB_comments.TextBox4.BackColor = RGB(175, 250, 175) And VB_comments.TextBox5.BackColor = RGB(250, 175, 100) Then
ActiveCell.offset(0, 6).Value = 4443

'C est rouge Q P D vert
ElseIf VB_comments.TextBox2.BackColor = RGB(175, 250, 175) And VB_comments.TextBox3.BackColor = RGB(175, 250, 175) And VB_comments.TextBox4.BackColor = RGB(175, 250, 175) And VB_comments.TextBox5.BackColor = RGB(250, 100, 100) Then
ActiveCell.offset(0, 6).Value = 4441

'___________________________________________________________________________________________________________________________

'Q rouge les autres noire
ElseIf VB_comments.TextBox2.BackColor = RGB(250, 100, 100) And VB_comments.TextBox3.BackColor = RGB(0, 0, 0) And VB_comments.TextBox4.BackColor = RGB(0, 0, 0) And VB_comments.TextBox5.BackColor = RGB(0, 0, 0) Then
ActiveCell.offset(0, 6).Value = 1222


'Q orange les autres noire
ElseIf VB_comments.TextBox2.BackColor = RGB(250, 175, 100) And VB_comments.TextBox3.BackColor = RGB(0, 0, 0) And VB_comments.TextBox4.BackColor = RGB(0, 0, 0) And VB_comments.TextBox5.BackColor = RGB(0, 0, 0) Then
ActiveCell.offset(0, 6).Value = 3222

'Q vert les autres noire
ElseIf VB_comments.TextBox2.BackColor = RGB(175, 250, 175) And VB_comments.TextBox3.BackColor = RGB(0, 0, 0) And VB_comments.TextBox4.BackColor = RGB(0, 0, 0) And VB_comments.TextBox5.BackColor = RGB(0, 0, 0) Then
ActiveCell.offset(0, 6).Value = 4222

'fixer Q D C

'P est rouge les autres noire
ElseIf VB_comments.TextBox2.BackColor = RGB(0, 0, 0) And VB_comments.TextBox3.BackColor = RGB(250, 100, 100) And VB_comments.TextBox4.BackColor = RGB(0, 0, 0) And VB_comments.TextBox5.BackColor = RGB(0, 0, 0) Then
ActiveCell.offset(0, 6).Value = 2122

'P est orange les autres noire
ElseIf VB_comments.TextBox2.BackColor = RGB(0, 0, 0) And VB_comments.TextBox3.BackColor = RGB(250, 175, 100) And VB_comments.TextBox4.BackColor = RGB(0, 0, 0) And VB_comments.TextBox5.BackColor = RGB(0, 0, 0) Then
ActiveCell.offset(0, 6).Value = 2322

'P est vert les autres noire
ElseIf VB_comments.TextBox2.BackColor = RGB(0, 0, 0) And VB_comments.TextBox3.BackColor = RGB(175, 250, 175) And VB_comments.TextBox4.BackColor = RGB(0, 0, 0) And VB_comments.TextBox5.BackColor = RGB(0, 0, 0) Then
ActiveCell.offset(0, 6).Value = 2422

'fixer P Q C

'D est rouge P Q C noire
ElseIf VB_comments.TextBox2.BackColor = RGB(0, 0, 0) And VB_comments.TextBox3.BackColor = RGB(0, 0, 0) And VB_comments.TextBox4.BackColor = RGB(250, 100, 100) And VB_comments.TextBox5.BackColor = RGB(0, 0, 0) Then
ActiveCell.offset(0, 6).Value = 2212

'D est orange P Q C noire
ElseIf VB_comments.TextBox2.BackColor = RGB(0, 0, 0) And VB_comments.TextBox3.BackColor = RGB(0, 0, 0) And VB_comments.TextBox4.BackColor = RGB(250, 175, 100) And VB_comments.TextBox5.BackColor = RGB(0, 0, 0) Then
ActiveCell.offset(0, 6).Value = 2232

'D est vert P Q C noire
ElseIf VB_comments.TextBox2.BackColor = RGB(0, 0, 0) And VB_comments.TextBox3.BackColor = RGB(0, 0, 0) And VB_comments.TextBox4.BackColor = RGB(175, 250, 175) And VB_comments.TextBox5.BackColor = RGB(0, 0, 0) Then
ActiveCell.offset(0, 6).Value = 2242

'fixer Q P D

'C est rouge Q P D noire
ElseIf VB_comments.TextBox2.BackColor = RGB(0, 0, 0) And VB_comments.TextBox3.BackColor = RGB(0, 0, 0) And VB_comments.TextBox4.BackColor = RGB(0, 0, 0) And VB_comments.TextBox5.BackColor = RGB(250, 100, 100) Then
ActiveCell.offset(0, 6).Value = 2221

'C est orange Q P D noire
ElseIf VB_comments.TextBox2.BackColor = RGB(0, 0, 0) And VB_comments.TextBox3.BackColor = RGB(0, 0, 0) And VB_comments.TextBox4.BackColor = RGB(0, 0, 0) And VB_comments.TextBox5.BackColor = RGB(250, 175, 100) Then
ActiveCell.offset(0, 6).Value = 2223

'C est vert Q P D noire
ElseIf VB_comments.TextBox2.BackColor = RGB(0, 0, 0) And VB_comments.TextBox3.BackColor = RGB(0, 0, 0) And VB_comments.TextBox4.BackColor = RGB(0, 0, 0) And VB_comments.TextBox5.BackColor = RGB(175, 250, 175) Then
ActiveCell.offset(0, 6).Value = 2224
'___________________________________________________________________________________________________________________________

End If

4 réponses

Zoul67 Messages postés 1959 Date d'inscription lundi 3 mai 2010 Statut Membre Dernière intervention 30 janvier 2023 149
18 mars 2019 à 14:53
Bonjour,

De manière générale, il faut éviter d'utiliser les couleurs...

Sinon, essaie (en remplacement de tout ton code !) :

coul_Q = 1000 * (1 * (VB_comments.TextBox2.BackColor = RGB(250, 100, 100)) + 2 * (VB_comments.TextBox2.BackColor = RGB(0, 0, 0)) + 3 * (VB_comments.TextBox2.BackColor = RGB(250, 175, 100)) + 4 * (VB_comments.TextBox2.BackColor = RGB(175, 250, 175)))
coul_P = 100 * (1 * (VB_comments.TextBox3.BackColor = RGB(250, 100, 100)) + 2 * (VB_comments.TextBox3.BackColor = RGB(0, 0, 0)) + 3 * (VB_comments.TextBox3.BackColor = RGB(250, 175, 100)) + 4 * (VB_comments.TextBox3.BackColor = RGB(175, 250, 175)))
coul_D = 10 * (1 * (VB_comments.TextBox4.BackColor = RGB(250, 100, 100)) + 2 * (VB_comments.TextBox4.BackColor = RGB(0, 0, 0)) + 3 * (VB_comments.TextBox4.BackColor = RGB(250, 175, 100)) + 4 * (VB_comments.TextBox4.BackColor = RGB(175, 250, 175)))
coul_C = 1 * (1 * (VB_comments.TextBox5.BackColor = RGB(250, 100, 100)) + 2 * (VB_comments.TextBox5.BackColor = RGB(0, 0, 0)) + 3 * (VB_comments.TextBox5.BackColor = RGB(250, 175, 100)) + 4 * (VB_comments.TextBox5.BackColor = RGB(175, 250, 175)))

ActiveCell.Offset(0, 6).Value = coul_Q + coul_P + coul_D + coul_C


A+
1
blalaa Messages postés 167 Date d'inscription mercredi 18 avril 2018 Statut Membre Dernière intervention 24 mars 2020
18 mars 2019 à 15:59
bonjour

merci ca a marche , au debut il affiche le chifre avec le signe (-) apres j'ai rajoute au debut de chque coul le signe (-) et ca fonctionne super
0
blalaa Messages postés 167 Date d'inscription mercredi 18 avril 2018 Statut Membre Dernière intervention 24 mars 2020
18 mars 2019 à 16:39
Re bonjour


comme vous pouvez le voire apres l'enregistrement de mes couleurs je voudrais faire la somme de Q qui sont en rouges et renvoyer la somme a une cellule specifiee , la somme de Q qui sont noire , Q qui sont en orange, la somme de Q qui sont vert
de mm pour les autres indicateurs a savoir P, D , C, je ne sais pas si c possible ou nn , si vous avez une idee merci d'avance pour votre aide.
0
Zoul67 Messages postés 1959 Date d'inscription lundi 3 mai 2010 Statut Membre Dernière intervention 30 janvier 2023 149
18 mars 2019 à 16:58
C'est faisable, mais il serait alors plus simple d'indiquer un chiffre par cellule (1 | 3 | 3 | 2 plutôt que 1332).
0
blalaa Messages postés 167 Date d'inscription mercredi 18 avril 2018 Statut Membre Dernière intervention 24 mars 2020
18 mars 2019 à 17:02
au faite j'ai que une seule colonne qui est libre (la colonne O) c pour ca jai mis le tt dans la mm cellule

c un doc que j'ai recupere
0
Zoul67 Messages postés 1959 Date d'inscription lundi 3 mai 2010 Statut Membre Dernière intervention 30 janvier 2023 149
18 mars 2019 à 17:07
Et les 16 résultats (Q,P,D,C) des 4 couleurs, on les met où ?
0
ccm81 Messages postés 10853 Date d'inscription lundi 18 octobre 2010 Statut Membre Dernière intervention 24 avril 2024 2 404
20 mars 2019 à 11:00
Bonjour à tous

Je ne sais pas si j'ai bien compris.
Un essai
https://www.cjoint.com/c/ICuj7yS0NzB

Cdlmnt
0
blalaa Messages postés 167 Date d'inscription mercredi 18 avril 2018 Statut Membre Dernière intervention 24 mars 2020
21 mars 2019 à 09:25
Bonjour


en fait c pas ce que je voulais, merci quand mm

pour le code des couleur monsieur Zoul67 me la passe et je le remerci par l'ocasion
voici le code

coul_Q = -1000 * (1 * (VB_comments.TextBox2.BackColor = RGB(250, 100, 100)) + 2 * (VB_comments.TextBox2.BackColor = RGB(0, 0, 0)) + 3 * (VB_comments.TextBox2.BackColor = RGB(250, 175, 100)) + 4 * (VB_comments.TextBox2.BackColor = RGB(175, 250, 175)))
coul_P = -100 * (1 * (VB_comments.TextBox3.BackColor = RGB(250, 100, 100)) + 2 * (VB_comments.TextBox3.BackColor = RGB(0, 0, 0)) + 3 * (VB_comments.TextBox3.BackColor = RGB(250, 175, 100)) + 4 * (VB_comments.TextBox3.BackColor = RGB(175, 250, 175)))
coul_D = -10 * (1 * (VB_comments.TextBox4.BackColor = RGB(250, 100, 100)) + 2 * (VB_comments.TextBox4.BackColor = RGB(0, 0, 0)) + 3 * (VB_comments.TextBox4.BackColor = RGB(250, 175, 100)) + 4 * (VB_comments.TextBox4.BackColor = RGB(175, 250, 175)))
coul_C = -1 * (1 * (VB_comments.TextBox5.BackColor = RGB(250, 100, 100)) + 2 * (VB_comments.TextBox5.BackColor = RGB(0, 0, 0)) + 3 * (VB_comments.TextBox5.BackColor = RGB(250, 175, 100)) + 4 * (VB_comments.TextBox5.BackColor = RGB(175, 250, 175)))

ActiveCell.Offset(0, 6).Value = coul_Q + coul_P + coul_D + coul_C


ce que je cherche maintenant c de faire la somme des couleurs

exemple

chque activite a 4 indicateur (Q P D C ) et chque indicateur va prendre une couleur qui peut etre rouge,noire,orange,vert

ce que je veux c un code pour faire la somme de chaque indicateur en fonction de sa couleur

comme ici jai mis si la couleur de lindicateur Q est rouge
la couleur de lindicateur Q est noiire
la couleur de lindicateur Q est orange
la couleur de lindicateur Q est vert

donc dans ma cellule je vais avoire un chiffre qui coresponds a ces couleurs la = 1234
le 1 signifie que lindicateur Q est rouge (si au lieu 1 c 3 ca signifie que la couleur de Q est orange .....)
le 2 signifie que lindicateur P est rouge (si au lieu 2 c 4 ca signifie que la couleur de P est vert .....)
le 3 signifie que lindicateur D est VERT (si au lieu 4 c 1 ca signifie que la couleur de D est rouge .....)
le 4 signifie que lindicateur C est vert (si au lieu 4 c 2 ca signifie que la couleur de P est Noire .....)

sachant yq plusieur activites alos jaurais plusieur chiffres bien sur dans des celluls differnet que jai specifie moi (comme montre dans limage)

maintenat je veux faire la somme pour chque indicateur en fonction de sa couluer par exemple

limage l'indicateur Q prend le chifre 1 dans 4 cellule et prend le chiffre 4 dans la derniere cellule

donc lindicateur Q est en rouge dans 4 activite et en vert dans une activite
mon code va faire la somme et jaurrais pour lindicateur Q
jai 4 Q en rouge et 1 Q en vert

je ne sai spas si c claire ou nn

mais si vous pouvez maider c serit vraiment gentil
je trouve pas la solution

merci davance
0
blalaa Messages postés 167 Date d'inscription mercredi 18 avril 2018 Statut Membre Dernière intervention 24 mars 2020
21 mars 2019 à 11:48
RE bonjour

jai mis ce code mais je ne sais pas comment l'adapter pour plusieurs cellule et commenet faire ensuit la somme


Sub g()

Dim a As Integer
Dim x, x1, y, y1, z As Integer


a = Left(Range("B1"), 1)

x = Left(Range("b1"), 2)
x1 = Right(x, 1)

y = Left(Range("b1"), 3)
y1 = Right(y, 1)

z = Right(Range("b1"), 1)

End Sub



en gros je recupere le premier chiffre apres le 2 eme apre le 3 eme et le 4 eme

mais je ne sais pas comment continuer

si vous avez une idee merci de me la partager
0
ccm81 Messages postés 10853 Date d'inscription lundi 18 octobre 2010 Statut Membre Dernière intervention 24 avril 2024 2 404
Modifié le 22 mars 2019 à 16:26
Quelque chose comme ça ?
https://www.cjoint.com/c/ICwpAxGFxiB

Cdlmnt
0
blalaa Messages postés 167 Date d'inscription mercredi 18 avril 2018 Statut Membre Dernière intervention 24 mars 2020
23 mars 2019 à 20:30
merci beaucoup
0