Alimentation d'une spreadsheet par un Userfom

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
 

Discussions similaires

Réponses
3
Affichages
647

Statistiques des forums

Discussions
312 595
Messages
2 090 095
Membres
104 374
dernier inscrit
cheick.coulibaly@dcsmali.