filierfilier
XLDnaute Junior
Bonjour,
je voudrai recopier en même temps, mais qu'une partie de donnée dans une autre feuille que celle de la destination de mon UserForm.
Explication
Dans un classeur Achats:
J'ai une Feuille recette ou je peux insérer des données avec le bouton " Créer une nouvelle recette "
J'ai une Feuille Liste des plats : Triées par nature de plat (7 au total)
Si je crée la recette Yabon (Nom_de_la_recette) en lui affectant comme nature : dessert (NatureControls) à partir de mon formulaire (voir ci joint)
Je voudrai que seulement la donnée Yabon se mette aussi dans la feuille Listes des plats mais à la suite du dernier enregistrement dans la colonne Dessert (qui elle même est une liste pour créer les menus) et ainsi de suite pour les autres recettes si cela est un plat ou une entrée ou un légumes etc ...
Voir fichier joint
Code pour l'insertion et création de fiche
Private Sub B_valider_Click()
'--- Contrôles ingredient et quantite 1
If Me.Ingredient_1 = "" Then
MsgBox "Veuillez saisir le nom de l'ingrédient 1!"
Me.Ingredient_1.SetFocus
Exit Sub
End If
If Me.Quantite_1 = "" Then
MsgBox "Veuillez saisir le poids de l'ingrédient 1!"
Me.Quantite_1.SetFocus
Exit Sub
End If
'--- Contrôles ingredient et quantite 2
If Me.Ingredient_2 = "" Then
MsgBox "Veuillez saisir le nom de l'ingrédient 2!"
Me.Ingredient_2.SetFocus
Exit Sub
End If
If Me.Quantite_2 = "" Then
MsgBox "Veuillez saisir le poids de l'ingrédient 2!"
Me.Quantite_2.SetFocus
Exit Sub
End If
'--- Contrôles ingredient et quantite 3
If Me.Ingredient_3 = "" Then
MsgBox "Veuillez saisir le nom de l'ingrédient 3!"
Me.Ingredient_3.SetFocus
Exit Sub
End If
If Me.Quantite_3 = "" Then
MsgBox "Veuillez saisir le poids de l'ingrédient 3!"
Me.Quantite_3.SetFocus
Exit Sub
End If
'--- Contrôles ingredient et quantite 4
If Me.Ingredient_4 = "" Then
MsgBox "Veuillez saisir le nom de l'ingrédient 4!"
Me.Ingredient_4.SetFocus
Exit Sub
End If
If Me.Quantite_4 = "" Then
MsgBox "Veuillez saisir le poids de l'ingrédient 4!"
Me.Quantite_4.SetFocus
Exit Sub
End If
'--- Contrôles ingredient et quantite 5
If Me.Ingredient_5 = "" Then
MsgBox "Veuillez saisir le nom de l'ingrédient 5!"
Me.Ingredient_5.SetFocus
Exit Sub
End If
If Me.Quantite_5 = "" Then
MsgBox "Veuillez saisir le poids de l'ingrédient 5!"
Me.Quantite_5.SetFocus
Exit Sub
End If
'--- Contrôles ingredient et quantite 6
If Me.Ingredient_6 = "" Then
MsgBox "Veuillez saisir le nom de l'ingrédient 6!"
Me.Ingredient_6.SetFocus
Exit Sub
End If
If Me.Quantite_6 = "" Then
MsgBox "Veuillez saisir le poids de l'ingrédient 6!"
Me.Quantite_6.SetFocus
Exit Sub
End If
'--- Contrôles ingredient et quantite 7
If Me.Ingredient_7 = "" Then
MsgBox "Veuillez saisir le nom de l'ingrédient 7!"
Me.Ingredient_7.SetFocus
Exit Sub
End If
If Me.Quantite_7 = "" Then
MsgBox "Veuillez saisir le poids de l'ingrédient 7!"
Me.Quantite_7.SetFocus
Exit Sub
End If
'--- Contrôles ingredient et quantite 8
If Me.Ingredient_8 = "" Then
MsgBox "Veuillez saisir le nom de l'ingrédient 8!"
Me.Ingredient_8.SetFocus
Exit Sub
End If
If Me.Quantite_8 = "" Then
MsgBox "Veuillez saisir le poids de l'ingrédient 8!"
Me.Quantite_8.SetFocus
Exit Sub
End If
'--- Positionnement dans la base
[A65000].End(xlUp).Offset(1, 0).Select
'--- Transfert Formulaire dans BD
ActiveCell.Offset(0, 1).Value = Me.Nom_de_la_recette
ActiveCell.Offset(0, 2).Value = Me.Ingredient_1
ActiveCell.Offset(0, 3).Value = Me.Quantite_1
ActiveCell.Offset(0, 4).Value = Me.Ingredient_2
ActiveCell.Offset(0, 5).Value = Me.Quantite_2
ActiveCell.Offset(0, 6).Value = Me.Ingredient_3
ActiveCell.Offset(0, 7).Value = Me.Quantite_3
ActiveCell.Offset(0, 8).Value = Me.Ingredient_4
ActiveCell.Offset(0, 9).Value = Me.Quantite_4
ActiveCell.Offset(0, 10).Value = Me.Ingredient_5
ActiveCell.Offset(0, 11).Value = Me.Quantite_5
ActiveCell.Offset(0, 12).Value = Me.Ingredient_6
ActiveCell.Offset(0, 13).Value = Me.Quantite_6
ActiveCell.Offset(0, 14).Value = Me.Ingredient_7
ActiveCell.Offset(0, 15).Value = Me.Quantite_7
ActiveCell.Offset(0, 16).Value = Me.Ingredient_8
ActiveCell.Offset(0, 17).Value = Me.Quantite_8
'-- Civilité
temp = ""
For Each c In Me.Nature.Controls
If c.Value = True Then
temp = c.Caption
End If
Next c
ActiveCell.Value = temp
'--
nettoie
End Sub
je voudrai recopier en même temps, mais qu'une partie de donnée dans une autre feuille que celle de la destination de mon UserForm.
Explication
Dans un classeur Achats:
J'ai une Feuille recette ou je peux insérer des données avec le bouton " Créer une nouvelle recette "
J'ai une Feuille Liste des plats : Triées par nature de plat (7 au total)
Si je crée la recette Yabon (Nom_de_la_recette) en lui affectant comme nature : dessert (NatureControls) à partir de mon formulaire (voir ci joint)
Je voudrai que seulement la donnée Yabon se mette aussi dans la feuille Listes des plats mais à la suite du dernier enregistrement dans la colonne Dessert (qui elle même est une liste pour créer les menus) et ainsi de suite pour les autres recettes si cela est un plat ou une entrée ou un légumes etc ...
Voir fichier joint
Code pour l'insertion et création de fiche
Private Sub B_valider_Click()
'--- Contrôles ingredient et quantite 1
If Me.Ingredient_1 = "" Then
MsgBox "Veuillez saisir le nom de l'ingrédient 1!"
Me.Ingredient_1.SetFocus
Exit Sub
End If
If Me.Quantite_1 = "" Then
MsgBox "Veuillez saisir le poids de l'ingrédient 1!"
Me.Quantite_1.SetFocus
Exit Sub
End If
'--- Contrôles ingredient et quantite 2
If Me.Ingredient_2 = "" Then
MsgBox "Veuillez saisir le nom de l'ingrédient 2!"
Me.Ingredient_2.SetFocus
Exit Sub
End If
If Me.Quantite_2 = "" Then
MsgBox "Veuillez saisir le poids de l'ingrédient 2!"
Me.Quantite_2.SetFocus
Exit Sub
End If
'--- Contrôles ingredient et quantite 3
If Me.Ingredient_3 = "" Then
MsgBox "Veuillez saisir le nom de l'ingrédient 3!"
Me.Ingredient_3.SetFocus
Exit Sub
End If
If Me.Quantite_3 = "" Then
MsgBox "Veuillez saisir le poids de l'ingrédient 3!"
Me.Quantite_3.SetFocus
Exit Sub
End If
'--- Contrôles ingredient et quantite 4
If Me.Ingredient_4 = "" Then
MsgBox "Veuillez saisir le nom de l'ingrédient 4!"
Me.Ingredient_4.SetFocus
Exit Sub
End If
If Me.Quantite_4 = "" Then
MsgBox "Veuillez saisir le poids de l'ingrédient 4!"
Me.Quantite_4.SetFocus
Exit Sub
End If
'--- Contrôles ingredient et quantite 5
If Me.Ingredient_5 = "" Then
MsgBox "Veuillez saisir le nom de l'ingrédient 5!"
Me.Ingredient_5.SetFocus
Exit Sub
End If
If Me.Quantite_5 = "" Then
MsgBox "Veuillez saisir le poids de l'ingrédient 5!"
Me.Quantite_5.SetFocus
Exit Sub
End If
'--- Contrôles ingredient et quantite 6
If Me.Ingredient_6 = "" Then
MsgBox "Veuillez saisir le nom de l'ingrédient 6!"
Me.Ingredient_6.SetFocus
Exit Sub
End If
If Me.Quantite_6 = "" Then
MsgBox "Veuillez saisir le poids de l'ingrédient 6!"
Me.Quantite_6.SetFocus
Exit Sub
End If
'--- Contrôles ingredient et quantite 7
If Me.Ingredient_7 = "" Then
MsgBox "Veuillez saisir le nom de l'ingrédient 7!"
Me.Ingredient_7.SetFocus
Exit Sub
End If
If Me.Quantite_7 = "" Then
MsgBox "Veuillez saisir le poids de l'ingrédient 7!"
Me.Quantite_7.SetFocus
Exit Sub
End If
'--- Contrôles ingredient et quantite 8
If Me.Ingredient_8 = "" Then
MsgBox "Veuillez saisir le nom de l'ingrédient 8!"
Me.Ingredient_8.SetFocus
Exit Sub
End If
If Me.Quantite_8 = "" Then
MsgBox "Veuillez saisir le poids de l'ingrédient 8!"
Me.Quantite_8.SetFocus
Exit Sub
End If
'--- Positionnement dans la base
[A65000].End(xlUp).Offset(1, 0).Select
'--- Transfert Formulaire dans BD
ActiveCell.Offset(0, 1).Value = Me.Nom_de_la_recette
ActiveCell.Offset(0, 2).Value = Me.Ingredient_1
ActiveCell.Offset(0, 3).Value = Me.Quantite_1
ActiveCell.Offset(0, 4).Value = Me.Ingredient_2
ActiveCell.Offset(0, 5).Value = Me.Quantite_2
ActiveCell.Offset(0, 6).Value = Me.Ingredient_3
ActiveCell.Offset(0, 7).Value = Me.Quantite_3
ActiveCell.Offset(0, 8).Value = Me.Ingredient_4
ActiveCell.Offset(0, 9).Value = Me.Quantite_4
ActiveCell.Offset(0, 10).Value = Me.Ingredient_5
ActiveCell.Offset(0, 11).Value = Me.Quantite_5
ActiveCell.Offset(0, 12).Value = Me.Ingredient_6
ActiveCell.Offset(0, 13).Value = Me.Quantite_6
ActiveCell.Offset(0, 14).Value = Me.Ingredient_7
ActiveCell.Offset(0, 15).Value = Me.Quantite_7
ActiveCell.Offset(0, 16).Value = Me.Ingredient_8
ActiveCell.Offset(0, 17).Value = Me.Quantite_8
'-- Civilité
temp = ""
For Each c In Me.Nature.Controls
If c.Value = True Then
temp = c.Caption
End If
Next c
ActiveCell.Value = temp
'--
nettoie
End Sub