Alimentation d'une spreadsheet par un Userfom

  • Initiateur de la discussion Initiateur de la discussion Oldevi
  • Date de début Date de début

Boostez vos compétences Excel avec notre communauté !

Rejoignez Excel Downloads, le rendez-vous des passionnés où l'entraide fait la force. Apprenez, échangez, progressez – et tout ça gratuitement ! 👉 Inscrivez-vous maintenant !

Oldevi

XLDnaute Nouveau
Bonjour à tous,

J'ai un formulaire Userform1 qui est alimenté par les feuilles "Anglais" ou "Français" suivant la valeur de la combobox "langue".
J'ai créé un Userform2 qui me permet de renseigner avec des listbox et des textbox les cellules de mes feuilles "Anglais" et "Français" (avec une clé qui permet la traduction suivant la langue selectionné) qui vont à leur tour alimenter mon Userform1.

Le code suivant marche, mais il créé des erreurs à la longue, je ne comprends pas vraiment pourquoi. Si quelqu'un à une idée pour le rendre plus efficace, ça m'aiderait beaucoup !

Merci d'avance.

Private Sub CommandButton1_Click()

S = Userform1.langue.Value

If S = "Français" Then
With Sheets(S)
lg = Userform1.nom.ListIndex + 2
Cl = .Cells(lg, 47).End(xlToLeft).Column + 1
.Cells(lg, Cl).Value = CBox2 & " - " & CBox3 & " - " & CBox4 & " - " & _
" (" & IIf(CBox5 = "", "", CBox5 & ", ") & _
IIf(CBox6 = "", "", CBox6 & "m€, ") & _
CBox7 & ")"
End With

With Sheets("Anglais")
lg = CréationCV.nom.ListIndex + 2
Cl = .Cells(lg, 47).End(xlToLeft).Column + 1
.Cells(lg, Cl).Value = Application.VLookup(CBox2, Sheets("clé").Range("A1:B72"), 2, False) & " - " & _
Application.VLookup(CBox3, Sheets("clé").Range("A1:B72"), 2, False) & " - " & _
CBox4 & " - " & " (" & IIf(CBox5 = "", "", CBox5 & ", ") & IIf(CBox6 = "", "", "€" & CBox6 & "m, ") & _
CBox7 & ")"
End With
End If

If S = "Anglais" Then
With Sheets(S)
lg = CréationCV.nom.ListIndex + 2
Cl = .Cells(lg, 47).End(xlToLeft).Column + 1
.Cells(lg, Cl).Value = CBox2 & " - " & CBox3 & " - " & CBox4 & " - " & _
" (" & IIf(CBox5 = "", "", CBox5 & ", ") & _
IIf(CBox6 = "", "", "€" & CBox6 & "m, ") & _
CBox7 & ")" & vbCrLf
End With

With Sheets("Français")
lg = CréationCV.nom.ListIndex + 2
Cl = .Cells(lg, 47).End(xlToLeft).Column + 1
.Cells(lg, Cl).Value = Application.VLookup(CBox2, Sheets("clé").Range("A1:B72"), 2, False) & " - " & _
Application.VLookup(CBox3, Sheets("clé").Range("A1:B72"), 2, False) & " - " & _
CBox4 & " - " & " (" & IIf(CBox5 = "", "", CBox5 & ", ") & IIf(CBox6 = "", "", CBox6 & "m€, ") & _
CBox7 & ")" & vbCrLf
End With

End If

Unload Me

Dim I As Byte
With Sheets(S)
For I = 2 To 47
Userform1("Box" & I) = .Cells(Userform1.nom.ListIndex + 2, I)
Next I
End With

Userform2.Show

End Sub
 
- Navigue sans publicité
- Accède à Cléa, notre assistante IA experte Excel... et pas que...
- Profite de fonctionnalités exclusives
Ton soutien permet à Excel Downloads de rester 100% gratuit et de continuer à rassembler les passionnés d'Excel.
Je deviens Supporter XLD

Discussions similaires

Réponses
5
Affichages
317
  • Question Question
Microsoft 365 worksheet_change
Réponses
29
Affichages
569
Réponses
3
Affichages
680
Réponses
7
Affichages
264
Retour