Précédent   Forum des professionnels en informatique > Logiciels > Microsoft Office > Excel > Macros et VBA Excel
Macros et VBA Excel Vos questions relatives aux macros Excel, à l'utilisation de VBA et à l'automatisation de vos classeurs Excel.
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 24/10/2011, 10h38   #1
Invité régulier
 
Homme Defter Defter
Dessinateur industriel
Inscription : mai 2011
Messages : 35
Détails du profil
Informations personnelles :
Nom : Homme Defter Defter
Localisation : France

Informations professionnelles :
Activité : Dessinateur industriel
Secteur : Bâtiment

Informations forums :
Inscription : mai 2011
Messages : 35
Points : 8
Points : 8
Par défaut Actualiser le liens combobox / Cellules

Bonjour,

J'ai actuellement trois combobox associées à trois cellules différentes

J'aimerai que lorsque j'effectue un choix dans la derniere des combobox les cellules reliés s'actualisent.

Je me sers de la maccro suivante :

Code :
1
2
3
4
5
6
7
Private Sub ComboBox5_change()
 
    Range("D43").Value = ComboBox3.Value
    Range("D44").Value = ComboBox4.Value
    Range("D45").Value = ComboBox5.Value
 
End Sub
Mais cela ne marche pas, ou pas à tout les coups : Seulement les deux première combobox sont parfons actualisés.

Je pense que c'est une erreur à ce niveau mais je ne sais pas quoi mettre d'autre.
J'ai essayé avec : mais le résultat est le même.

Auriez-vous une idée ?

Cordialement,
Defter.
Defter est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 24/10/2011, 10h49   #2
Expert Confirmé Sénior
 
Avatar de jfontaine
 
Homme Jérôme FONTAINE
Contrôleur de Gestion
Inscription : juin 2006
Messages : 3 905
Détails du profil
Informations personnelles :
Nom : Homme Jérôme FONTAINE
Âge : 38
Localisation : France, Sarthe (Pays de la Loire)

Informations professionnelles :
Activité : Contrôleur de Gestion

Informations forums :
Inscription : juin 2006
Messages : 3 905
Points : 7 196
Points : 7 196
Bonjour,

Si tu veux aussi une actualisation lors de la modification des Combo 3 et 4, il faut aussi mettre le code dans leurs évènements Change


Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
Private Sub ComboBox3_change()
MAJ
End Sub
 
Private Sub ComboBox4_change()
MAJ
End Sub
 
Private Sub ComboBox5_change()
MAJ
End Sub
 
Sub MAJ
    Range("D43").Value = ComboBox3.Value
    Range("D44").Value = ComboBox4.Value
    Range("D45").Value = ComboBox5.Value
End Sub
__________________
Jérôme

Citation:
"Ils ne savaient pas que c'était impossible, alors ils l'ont fait" - Marc Twain
Si la réponse répond à votre besoin, votre vote nous encouragera.
Dans le cas ou la réponse mérite, à vos yeux, un , nous faire partager la raison de ce vote, pourrait nous permettre de nous améliorer.
jfontaine est actuellement connecté   Envoyer un message privé Réponse avec citation 10
Vieux 24/10/2011, 10h57   #3
Invité régulier
 
Homme Defter Defter
Dessinateur industriel
Inscription : mai 2011
Messages : 35
Détails du profil
Informations personnelles :
Nom : Homme Defter Defter
Localisation : France

Informations professionnelles :
Activité : Dessinateur industriel
Secteur : Bâtiment

Informations forums :
Inscription : mai 2011
Messages : 35
Points : 8
Points : 8
Bonjour jfontaine et merci pour ta réponse.

Enfaite mes combobox 3, 4 et 5 sont actualisées via un choix effectué dans la combobox 2

Le code est un peu long mais si ça peut aider à comprendre :

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
Private Sub ComboBox2_Click()
    Dim Poteau_Serreur As String, Poteau_VEC As String, Poteau_SOF As String, Poteau_VEP As String, Poteau_1100Serreur As String, Cadre_Serreur As String, Cadre_VEC As String, Cadre_SOF As String, Cadre_VEP As String, Cadre_1100Serreur As String, Joint_Serreur As String, Joint_VEC As String, Joint_SOF As String, Joint_VEP As String, Joint_1100Serreur As String
    Poteau_Serreur = "Data!C59:C65"
    Poteau_VEC = "Data!A59:A60"
    Poteau_SOF = "Data!D59:D60"
    Poteau_VEP = "Data!B59:B61"
    Poteau_1100Serreur = "Data!E59:E60"
    Cadre_VEC = "Data!G59:G62"
    Cadre_VEP = "Data!H59:H62"
    Cadre_Serreur = "Data!I59:I61"
    Cadre_SOF = "Data!J59:J61"
    Cadre_1100Serreur = "Data!K59:K60"
    Joint_VEC = "Data!A71:A75"
    Joint_VEP = "Data!B71:B73"
    Joint_Serreur = "Data!C71:C73"
    Joint_SOF = "Data!D71"
    Joint_1100Serreur = "Data!E71"
        With Sheets("Data")
            If .Range("B43").Value = "W80" And .Range("B49").Value = "VEC" Then
                ActiveSheet.ComboBox3.ListFillRange = Poteau_VEC
                ActiveSheet.ComboBox3.ListIndex = 0
                ActiveSheet.ComboBox3.ListRows = 2
            End If
            If .Range("B43").Value = "W80" And .Range("B49").Value = "VEP" Then
                Me.ComboBox3.ListFillRange = Poteau_VEP
                Me.ComboBox3.ListIndex = 0
                Me.ComboBox3.ListRows = 3
            End If
            If .Range("B43").Value = "W44" And .Range("B49").Value = "Serreur" Then
                Me.ComboBox3.ListFillRange = Poteau_Serreur
                Me.ComboBox3.ListIndex = 0
                Me.ComboBox3.ListRows = 6
            End If
            If .Range("B43").Value = "W44" And .Range("B49").Value = "Serreur+OF" Then
                Me.ComboBox3.ListFillRange = Poteau_SOF
                Me.ComboBox3.ListIndex = 0
                Me.ComboBox3.ListRows = 2
            End If
            If .Range("B43").Value = "1100" And .Range("B49").Value = "Serreur" Then
                Me.ComboBox3.ListFillRange = Poteau_1100Serreur
                Me.ComboBox3.ListIndex = 0
                Me.ComboBox3.ListRows = 2
            End If
            If .Range("B43").Value = "W80" And .Range("B49").Value = "VEC" Then
                Me.ComboBox4.ListFillRange = Cadre_VEC
                Me.ComboBox4.ListIndex = 0
                Me.ComboBox4.ListRows = 4
            End If
            If .Range("B43").Value = "W80" And .Range("B49").Value = "VEP" Then
                Me.ComboBox4.ListFillRange = Cadre_VEP
                Me.ComboBox4.ListIndex = 0
                Me.ComboBox4.ListRows = 4
            End If
            If .Range("B43").Value = "W44" And .Range("B49").Value = "Serreur" Then
                Me.ComboBox4.ListFillRange = Cadre_Serreur
                Me.ComboBox4.ListIndex = 0
                Me.ComboBox4.ListRows = 3
            End If
            If .Range("B43").Value = "W44" And .Range("B49").Value = "Serreur+OF" Then
                Me.ComboBox4.ListFillRange = Cadre_SOF
                Me.ComboBox4.ListIndex = 0
                Me.ComboBox4.ListRows = 3
            End If
            If .Range("B43").Value = "1100" And .Range("B49").Value = "Serreur" Then
                Me.ComboBox4.ListFillRange = Cadre_1100Serreur
                Me.ComboBox4.ListIndex = 0
                Me.ComboBox4.ListRows = 2
            End If
            If .Range("B43").Value = "W80" And .Range("B49").Value = "VEC" Then
                Me.ComboBox5.ListFillRange = Joint_VEC
                Me.ComboBox5.ListIndex = 0
                Me.ComboBox5.ListRows = 5
            End If
            If .Range("B43").Value = "W80" And .Range("B49").Value = "VEP" Then
                Me.ComboBox5.ListFillRange = Joint_VEP
                Me.ComboBox5.ListIndex = 0
                Me.ComboBox5.ListRows = 3
            End If
            If .Range("B43").Value = "W44" And .Range("B49").Value = "Serreur" Then
                Me.ComboBox5.ListFillRange = Joint_Serreur
                Me.ComboBox5.ListIndex = 0
                Me.ComboBox5.ListRows = 3
            End If
            If .Range("B43").Value = "W44" And .Range("B49").Value = "Serreur+OF" Then
                Me.ComboBox5.ListFillRange = Joint_SOF
                Me.ComboBox5.ListIndex = 0
                Me.ComboBox5.ListRows = 1
            End If
            If .Range("B43").Value = "1100" And .Range("B49").Value = "Serreur" Then
                Me.ComboBox5.ListFillRange = Joint_1100Serreur
                Me.ComboBox5.ListIndex = 0
                Me.ComboBox5.ListRows = 1
            End If
        End With
End Sub
Comme tu peux le remarquer la combobox 2 est définit en _Click,
Dois-je changer au profit de _Change ?

Dans ce cas précis, ou positioné la commande MAJ ?


Cordialement,
Defter
Defter est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 24/10/2011, 11h23   #4
Invité régulier
 
Homme Defter Defter
Dessinateur industriel
Inscription : mai 2011
Messages : 35
Détails du profil
Informations personnelles :
Nom : Homme Defter Defter
Localisation : France

Informations professionnelles :
Activité : Dessinateur industriel
Secteur : Bâtiment

Informations forums :
Inscription : mai 2011
Messages : 35
Points : 8
Points : 8
Je reviens pour dire que j'ai résolu mon problème,

Merci JFontaine pour l'info !

Donc à la suite de mon code j'ai rajouté comme tu as précisé :

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
Private Sub ComboBox3_Click()
 
MAJ
 
End Sub
Private Sub ComboBox4_Click()
 
MAJ
 
End Sub
Private Sub ComboBox5_Click()
 
MAJ
 
End Sub
 
Sub MAJ()
 
    Sheets("Data").Range("D43").Value = ComboBox3.Value
    Sheets("Data").Range("D44").Value = ComboBox4.Value
    Sheets("Data").Range("D45").Value = ComboBox5.Value
 
End Sub
Ca marche parfaitement, merci beaucoup pour l'aide apportée

A bientôt
Defter
Defter est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 11h48.


 
 
 
 
Partenaires

Hébergement Web