[RESOLU par Lone-wolf.jecherche.Chris24] : COMBOBOX en CASCADE

MADAGASCAR

XLDnaute Occasionnel
Bonjour EXCEL DOWNLOADS
Bonjour à tous et à toutes
Cher gentelman ..
Je sollicite une autre fois vos aides si vous pouvez m'aider a finir ce fichier
ComboBox1 alimentee par (mada1.mada2.mada3)
ComboBox2 alimentee par des chiffres de 1 à 12
Des je choisis un nom dans ComboBox1 s'affichera un nombre dans TextBox1 .. ici pas probleme
Mon probleme c'est avec le TextBox2 .. je veux faire si vous pouvez m'aider bien sur :
Si je choisis dans :
ComboBox1 "mada1" et dans ComboBox2 "1" alors s'affichera dans TextBox2 le chiffre "123456"
ComboBox1 "mada1" et dans ComboBox2 "2" alors s'affichera dans TextBox2 le chiffre "851278"
ComboBox1 "mada1" et dans ComboBox2 "3" alors s'affichera dans TextBox2 le chiffre "957272"

ComboBox1 "mada2" et dans ComboBox2 "1" alors s'affichera dans TextBox2 le chiffre "444888"
ComboBox1 "mada2" et dans ComboBox2 "2" alors s'affichera dans TextBox2 le chiffre "823001"
ComboBox1 "mada2" et dans ComboBox2 "3" alors s'affichera dans TextBox2 le chiffre "478235"

ComboBox1 "mada3" et dans ComboBox2 "1" alors s'affichera dans TextBox2 le chiffre "214789"
ComboBox1 "mada3" et dans ComboBox2 "2" alors s'affichera dans TextBox2 le chiffre "589723"
ComboBox1 "mada3" et dans ComboBox2 "3" alors s'affichera dans TextBox2 le chiffre "369852"

Merci beaucoup d'avance pour l'aide
Tres cordialement
MADA BLACK
 

Pièces jointes

  • ComboBox cascade.xlsm
    20.6 KB · Affichages: 43
Dernière édition:

Lone-wolf

XLDnaute Barbatruc
Re : COMBOBOX en CASCADE

I MADA ;)

Je te donne juste l'exemple, à toi de finir la macro.

Code:
Private Sub ComboBox2_Change()
If ComboBox1.Text = "mada1" Then
If ComboBox2 = 1 Then
TextBox2.Value = 123456
ElseIf ComboBox2 = 2 Then
TextBox2.Value = 851278
ElseIf ComboBox2.Text = 3 Then
TextBox2.Value = 957272
End If
End If

'A répéter pour mada2 et mada3

End Sub


A+ :cool:
 
Dernière édition:

MADAGASCAR

XLDnaute Occasionnel
Re : COMBOBOX en CASCADE

Bonsoir cher Lone-wolf
Ravi .. tres ravi de vous rencontrer dans ce sujet
Merci beaucoup pour votre aide
Oui c'est effectivement ce que je veux voir et avoir
C'est parfaitement resolu
Tres cordialement
MADA
 

jecherche

XLDnaute Occasionnel
Re : [RESOLU par Lone-wolf] : COMBOBOX en CASCADE

Bonjour,

Une autre façon :
Code:
Public X As Byte

Private Sub CommandButton1_Click()
  End
End Sub

Private Sub UserForm_Initialize()
  ComboBox1.AddItem ("-----------------"): ComboBox1.AddItem ("mada1"): ComboBox1.AddItem ("mada2"): ComboBox1.AddItem ("mada3")
  ComboBox2.AddItem ("1"): ComboBox2.AddItem ("2"): ComboBox2.AddItem ("3")
End Sub

Private Sub Combobox1_Click()
Dim BASE(0 To 10)
  BASE(0) = "--------------": BASE(1) = "99874.00": BASE(2) = "54782.00": BASE(3) = "42880.00"
  TextBox1.Text = BASE(ComboBox1.ListIndex)
  X = ComboBox1.ListIndex
  Traitement
End Sub

Private Sub Combobox2_Click()
  Traitement
End Sub

Private Sub Traitement()

Dim BASE(0 To 10)
  Select Case X + 1
  Case 2
    BASE(0) = "--------------": BASE(1) = "123456.00": BASE(2) = "444888.00": BASE(3) = "957272.00"
    TextBox2.Text = BASE(ComboBox2.ListIndex + 1)
  Case 3
    BASE(0) = "--------------": BASE(1) = "851278.00": BASE(2) = "823001.00": BASE(3) = "589723.00"
    TextBox2.Text = BASE(ComboBox2.ListIndex + 1)
  Case 4
    BASE(0) = "--------------": BASE(1) = "957272.00": BASE(2) = "478235.00": BASE(3) = "369852.00"
    TextBox2.Text = BASE(ComboBox2.ListIndex + 1)
  Case Else
    TextBox2.Text = ""
  End Select
TextBox2.Text = BASE(ComboBox2.ListIndex + 1)
End Sub

À évaluer

Jecherche
 
Dernière modification par un modérateur:

Chris24

XLDnaute Impliqué
Re : [RESOLU par Lone-wolf et jecherche] : COMBOBOX en CASCADE

Bonsoir

Une autre solution avec mise à jour de textebox2 si tu changes combobox1 sans changer combobox2

Bonne soirée
 

Pièces jointes

  • ComboBox cascade_mada.xlsm
    17.5 KB · Affichages: 38
Dernière modification par un modérateur:

jecherche

XLDnaute Occasionnel
Re : [RESOLU par Lone-wolf et jecherche] : COMBOBOX en CASCADE

Bonjour,

Pour faire du pouce sur l'approche de Cris24 à propos de l'actualisation du Textbox2 quand on change subséquemment le TextBox1...
J'ai modifié le code du post #4


Jecherche
 
Dernière modification par un modérateur:

MADAGASCAR

XLDnaute Occasionnel
Re : [RESOLU par Lone-wolf et jecherche] : COMBOBOX en CASCADE

Bonsoir Chris24
Merci beaucoup pour l'aide
Vous avez raison .. j'ai remarqué qu'il me manque une chose .. amis j'ai pas pu la definir
Et maintenant avec votre fichier .. j'ai trouvé ce que je cherche
Merci encore cher gentelman Chris24
Merci encore cher gentelman jecherche
Cordialement
MADA BLACK
 

Discussions similaires

Réponses
10
Affichages
379

Statistiques des forums

Discussions
312 214
Messages
2 086 311
Membres
103 175
dernier inscrit
abcc