|
|
|
|
Salut à tous, petit problème avec mon comboBox. J'ai un userform1 avec textBox et ComboBox, dans le combobox 1 j'ai une liste avec les mois, je voudrais que quand je selection janvier les résultat des autre comboBox et textBox s'inscrivent dans la feuille Janvier, si selection février dans feuille février et ainsi de suite. j'ai se code là
Merci de bien vouloir m'aider. A+
Configuration: Windows XP excel 2007 Firefox 3.0.6
Bonjour
|
Bonjour,
' Met en place les données dans les cellules de la feuille de calcul
Private Sub CommandButton1_Click()
Dim i As Byte, Nom As String, DerLig As Long
Dim Dum As String, Longueur As Integer
Nom = ComboBox1.Value
Dum = Right(Nom, 2)
Longueur = Len(Nom)
Nom = Mid(Nom, 1, (Longueur - 4))
Nom = Nom & Dum
Nom = LCase(Nom)
Nom = Trim(Nom)
Dum = UCase(Left(Nom, 1))
Nom = Dum & Mid(Nom, 2)
With Sheets(Nom)
DerLig = .Range("A65536").End(xlUp).Row + 1
.Cells(DerLig, 1) = ComboBox2
.Cells(DerLig, 2) = ComboBox3
.Cells(DerLig, 3) = TextBox3
.Cells(DerLig, 4) = ComboBox5
.Cells(DerLig, 5) = ComboBox4
.Cells(DerLig, 6) = ComboBox6
.Cells(DerLig, 7) = TextBox1
.Cells(DerLig, 8) = TextBox2
End With
Unload Me
End Sub
'
autre recommandation, dans la routine : [ Private Sub ComboBox3_Change() ] vous devriez écrire comme ceci :
' Faire apparaitre un textBox suivant la sélection dans la ComboBox
Private Sub ComboBox3_Change()
Select Case ComboBox3.Value
Case "CB"
TextBox1.Visible = True 'afficher
TextBox2.Visible = False 'Cacher
TextBox3.Visible = False 'Cacher
Case "CB Internet"
TextBox1.Visible = True 'afficher
TextBox2.Visible = False 'Cacher
TextBox3.Visible = False 'Cacher
Case "CB Retrait"
TextBox1.Visible = True 'afficher
TextBox2.Visible = False 'Cacher
TextBox3.Visible = False 'Cacher
Case "Chèque"
TextBox1.Visible = True 'afficher
TextBox2.Visible = False 'TextBox pour le créditCacher
TextBox3.Visible = True 'TextBox pour rentrer le N° chèque affiche
Case "Prélèvement "
TextBox1.Visible = True 'afficher
TextBox2.Visible = False 'Cacher
TextBox3.Visible = False 'Cacher
Case "Prélèvement CB"
TextBox1.Visible = True 'afficher
TextBox2.Visible = False 'Cacher
TextBox3.Visible = False 'Cacher
Case "Retrait Chèque"
TextBox1.Visible = True 'afficher
TextBox2.Visible = False 'Cacher
TextBox3.Visible = False 'Cacher
Case "Virement"
TextBox1.Visible = False 'cacher
TextBox2.Visible = True 'Afficher
TextBox3.Visible = False 'Cacher
Case "Rem Chèque"
TextBox1.Visible = False 'Cacher
TextBox2.Visible = True 'Afficher
TextBox3.Visible = False 'Cacher
Case "Virement"
TextBox1.Visible = False 'Cacher
TextBox2.Visible = True 'Afficher
TextBox3.Visible = False 'Cacher
Case "Rem Liquide"
TextBox1.Visible = False 'Cacher
TextBox2.Visible = True 'Afficher
TextBox3.Visible = False 'Cacher
Case "Rem Niveau"
TextBox1.Visible = False 'Cacher
TextBox2.Visible = True 'Afficher
TextBox3.Visible = False 'Cacher
End Select
End Sub
'
Lupin |
Re:
' Met en place les données dans les cellules de la feuille de calcul
Private Sub CommandButton1_Click()
Dim i As Byte, Nom As String, DerLig As Long
Dim Dum As String, Longueur As Integer
Nom = ComboBox1.Value
Dum = Right(Nom, 2)
Longueur = Len(Nom)
Nom = Mid(Nom, 1, (Longueur - 4))
Nom = Nom & Dum
Nom = LCase(Nom)
Nom = Trim(Nom)
Dum = UCase(Left(Nom, 1))
Nom = Dum & Mid(Nom, 2)
DerLig = Sheets(Nom).Range("A65536").End(xlUp).Row + 1
With Sheets(Nom)
.Cells(DerLig, 1) = ComboBox2
.Cells(DerLig, 3) = ComboBox3
.Cells(DerLig, 4) = TextBox3
.Cells(DerLig, 5) = ComboBox5
.Cells(DerLig, 6) = ComboBox4
.Cells(DerLig, 7) = ComboBox6
.Cells(DerLig, 8) = TextBox1
.Cells(DerLig, 9) = TextBox2
End With
Unload Me
End Sub
'
Lupin |