VBA excel ComboBox

Résolu
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+

'Met en place les données dans les cellules de la feuille de calcul'
Private Sub CommandButton1_Click() 'bouton enregistrer'
Dim i As Byte, Nom As String
Dim DerLig As Long
Nom = ComboBox1
With Sheets(Nom)
DerLig = .Range("A65536").End(xlUp).Row + 1
.Cells(DerLig, 1) = CombiBox2
.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
Configuration: Windows XP excel 2007
Firefox 3.0.6

4 réponses

  1. re:

    Autre point :

    Pour que l'instruction [ DerLig = .Range("A65536").End(xlUp).Row + 1 ] fonctionne bien

    Placer en A4 de chaque page [ Janvier ... Décembre ] la valeur 0 et placer la couleur du texte
    en Blanc.

    Et voici ler code :
    ' 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
    0
    1. Bonjour,

      un des problèmes est que les noms figurants dans la feuille "Listes" ne correspondent pas
      aux noms des feuilles associées.

      Dans la routine : [ Private Sub CommandButton1_Click() ]

      J'ai du manipuler la valeur du ComboBox comme suit :
      ' 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
      0
      1. Contributeur
        re:

        dans ta combobox tu as JANVIER 2009 et tes feuilles sont nommées Janvier 2009 (majuscules, minuscules)
        0
        1. Contributeur
          Bonjour

          selon ce que j'en lis, le code affiché (mise à part des fautes de frappe : combibox) doit faire ce que tu demandes, à la seule condition que les noms de feuille soient exactement identiques aux valeurs contenues dans la combobox
          1
          1. Bonjour WilFried, je n'arrive pas à trouver erreur peut tu m'aider, je te met mon fichier à l'adresse ci-dessous
            et Merci.

            http://www.cijoint.fr/cjlink.php?file=cj200902/cijqBsigOx.xls
            0