Ceci est une page optimisée pour les mobiles. Cliquez sur ce texte pour afficher la vraie page.

Problème code VBA pour modification de données à partir d'un userform

flog_gui

XLDnaute Nouveau
Bonjour !

J'ai crée un userform qui est censé modifier une carte de restaurant, plus précisément les menus préexistants dans cette carte. Pour chaque menu, on choisit l'entrée le plat le dessert à modifier et on en inscrit un nouveau dans la textbox qui suit.

Je n'arrive pas à voir d'où vient le problème dans le code ; quand je fais marcher l'userform, je peux sélectionner les plats sans problème, mais quand je rentre un nom nouveau, aucune modification ne s'effectue...
Quelqu'un voit-il le problème ? Toutes vos remarques sont les bienvenues !
Merci d'avance

Private Sub ComboBox1_Afterupdate()

Sheets("Carte").Activate

If ComboBox1.Value = "Gourmand" Then ComboBox2.RowSource = "Carte!B45:B47"
If ComboBox1.Value = "Gourmand" Then ComboBox4.RowSource = "Carte!B49:B51"
If ComboBox1.Value = "Gourmand" Then ComboBox6.RowSource = "Carte!B53:B55"

If ComboBox1.Value = "Plaisir" Then ComboBox2.RowSource = "Carte!D4547"
If ComboBox1.Value = "Plaisir" Then ComboBox4.RowSource = "Carte!D4951"
If ComboBox1.Value = "Plaisir" Then ComboBox6.RowSource = "Carte!D5355"

If ComboBox1.Value = "Express" Then ComboBox2.RowSource = ""
If ComboBox1.Value = "Express" Then ComboBox4.RowSource = "Carte!F45:F47"
If ComboBox1.Value = "Express" Then ComboBox26.RowSource = "Carte!F50:F53"

If ComboBox1.Value = "Enfant" Then ComboBox2.RowSource = ""
If ComboBox1.Value = "Enfant" Then ComboBox4.RowSource = "Carte!H45:H47"
If ComboBox1.Value = "Enfant" Then ComboBox6.RowSource = "Carte!H49:H51"


End Sub

Private Sub ComboBox2_Change()

Sheets("Carte").Select


If ComboBox1.Value = "Gourmand" Then Range("B45").Select
If ComboBox1.Value = "Plaisir" Then Range("D45").Select
If ComboBox1.Value = "Express" Then Range("F45").Select
If ComboBox1.Value = "Enfant" Then Range("H45").Select

Do
If ActiveCell.Value = Menuchange!ComboBox2 Then
GoTo Modifier2
End If

If ActiveCell.Value <> Menuchange!ComboBox2 Then
ActiveCell.Offset(1, 0).Select
End If

Loop Until ActiveCell.Value = ""

Modifier2:
ActiveCell.Value = Menuchange!TextBox2



End Sub

Private Sub ComboBox4_Change()

Sheets("Carte").Select

If ComboBox1.Value = "Gourmand" Then Range("B49").Select
If ComboBox1.Value = "Plaisir" Then Range("D49").Select
If ComboBox1.Value = "Express" Then Range("F45").Select
If ComboBox1.Value = "Enfant" Then Range("H45").Select

Do
If ActiveCell.Value = Menuchange!ComboBox4 Then
GoTo Modifier4
End If

If ActiveCell.Value <> Menuchange!ComboBox4 Then
ActiveCell.Offset(1, 0).Select
End If

Loop Until ActiveCell.Value = ""

Modifier4:
ActiveCell.Value = Menuchange!TextBox3


End Sub

Private Sub ComboBox6_Change()

Sheets("Carte").Select

If ComboBox1.Value = "Gourmand" Then Range("B53").Select
If ComboBox1.Value = "Plaisir" Then Range("D53").Select
If ComboBox1.Value = "Express" Then Range("F49").Select
If ComboBox1.Value = "Enfant" Then Range("H49").Select

Do
If ActiveCell.Value = Menuchange!ComboBox6 Then
GoTo Modifier6
End If

If ActiveCell.Value <> Menuchange!ComboBox6 Then
ActiveCell.Offset(1, 0).Select
End If

Loop Until ActiveCell.Value = ""

Modifier6:
ActiveCell.Value = Menuchange!TextBox4


End Sub

Private Sub CommandButton1_Click()

Sheets("Carte").Select

If ComboBox1.Value = "Gourmand" Then Range("C43").Select
If ComboBox1.Value = "Plaisir" Then Range("E43").Select
If ComboBox1.Value = "Express" Then Range("G43").Select
If ComboBox1.Value = "Enfant" Then Range("I43").Select

ActiveCell.Value = Menuchange!TextBox1

Sheets("Carte").Select


End Sub

Private Sub CommandButton2_Click()

Unload Me


End Sub
 

flog_gui

XLDnaute Nouveau
Re : Problème code VBA pour modification de données à partir d'un userform

Bonjour,

Merci pour la rapidité de votre réponse !
Pour être franche, je ne sais ni ce qu'est un item ni la méthode additem...
 

Discussions similaires

Les cookies sont requis pour utiliser ce site. Vous devez les accepter pour continuer à utiliser le site. En savoir plus…