Bouton commande pour afficher une feuille excel

Résolu
PinkS13 Messages postés 8 Date d'inscription   Statut Membre Dernière intervention   -  
PinkS13 Messages postés 8 Date d'inscription   Statut Membre Dernière intervention   -
Bonjour,

J'ai fais cette fonction pour appuyer sur un "commanbutton" et afficher une liste sur la feuille DDN:

Private Sub CommandButton2_Click()
Sheets("DDN").Select
End Sub

Par contre la feuille s'affiche mais comme elle a environ 2000 lignes, je ne suis pas capable de faire descendre et d'aller dans la feuille. J'ai seulement accès à la voir jusqu'à la ligne 16 environ.

Comment puis-je faire pour pouvoir descendre sur la feuille que j'ai affiché sans être obligé de quitter mon formulaire ?

Merci

3 réponses

  1. M-12 Messages postés 1349 Statut Membre 285
     
    Bonsoir,

    dans l'instruction qui lance ton userform, ajoute "0" pour le mettre ne mode "non modal"

    UserForm.Show 0


    Cela te permettra de visualiser l'onglet (ou la feuille) que tu "ACTIVATE (ou lieu de select)
    0
  2. PinkS13 Messages postés 8 Date d'inscription   Statut Membre Dernière intervention  
     
    Excuse mon ignorance, mais peux-tu me dire où le mettre ? Voici mon code complet

    ' Combobox 1= département
    'COMBOBOX 2 = type de document
    'Combobox 3: DDN
    ' Textbox2 =  description
    ' Texbox3 = Date
    ' Texbox4 = createur annulé
    ' Texbox 5: Révision
    
    'QUAND ON CLIQUE SUR BOUTON POUR TERMINER LES ENTRÉES DE DONNÉES
    Private Sub CommandButton1_Click()
    ' SI UNE CASE EST VIDE OU LA DATE N'EST PAS INDIQUÉ = AFFICHER MESSAGE MSGBOX
    If ComboBox1 = "" Or ComboBox3 = "" Or ComboBox2 = "" Or TextBox2 = "" Or TextBox3 = "" Or TextBox3 = "AAAA/MM/JJ" Or TextBox5 = "" Then
    MsgBox ("Toutes les cases doivent être remplies")
    Else
    ' SI LA CASE A6 EST VIDE, Y INCLURE LES INFORMATIONS DE COMBOBOX1 CATÉGORIE
    If Sheets("Feuil1").Range("a6") = "" Then
    Sheets("Feuil1").Range("a6") = ComboBox1
    'SINON AJOUTE UNE LIGNE
    Else
    Sheets("Feuil1").ListObjects(1).ListRows.Add
        End If
    'PRENDS LE NUMÉRO DE LA DERNIÈRE LIGNE QUI DERA = DLT
        dlt = Sheets("Feuil1").Range("d1048576").End(xlUp).Row
        
    'COPIE LA CATÉGORIE DANS CASE A DE LA DERNIÈRE LIGNE = COMBOBOX1
     Sheets("Feuil1").Range("a" & dlt) = ComboBox1
     
     'COPIE LA RÉVISION DANS LA CASE f DE LA DERNIÈRE LIGNE
    
     TextBox5 = Format(TextBox5, "00")
     Sheets("Feuil1").Range("f" & dlt) = TextBox5.Value
    
    'COPIE LA DESCRIPTION DANS LA DERNIÈRE LIGNE DE LA CASE C
       Sheets("Feuil1").Range("d" & dlt) = TextBox2
       
    'COPIE LA DATE DANS LA DERNIÈRE LIGNE DE LA CASE h
       TextBox3 = Format(TextBox3, "MM/DD/YYYY")
        Sheets("Feuil1").Range("G" & dlt) = TextBox3.Value
        
    'COPIE LE TYPE DE FICHIER DANS LA DERNIÈRE LIGNE DE LA CASE b
    Sheets("Feuil1").Range("b" & dlt) = ComboBox2
        
    'COPIE LE DDN DANS LA DERNIÈRE LIGNE DE LA CASE c
    Sheets("Feuil1").Range("c" & dlt) = ComboBox3
    
    ' ajoute un numéro implémenté
    Dim va As Double
    va = 0
    For r = 6 To 2500
    If Range("l" & r).Value > va Then
    va = Range("l" & r).Value
    End If
    Next r
    Sheets("Feuil1").Range("l" & dlt) = va + 1
    
    
    'COPIE LE DDN DANS LA DERNIÈRE LIGNE DE LA CASE i
    
    With Sheets("DDN")
    cherche = ComboBox3.Value
    lig = .Columns("A").Find(what:=cherche, after:=Range("A7"), LookIn:=xlValues).Row
    End With
    
    'COPIE RÉSULTAT DDN
    ' DIV = i
    'Item = J
    'Det=k
    
    Sheets("Feuil1").Range("h" & dlt) = Sheets("DDN").Range("c" & lig).Value
    Sheets("Feuil1").Range("i" & dlt) = Sheets("DDN").Range("d" & lig).Value
    Sheets("Feuil1").Range("j" & dlt) = Sheets("DDN").Range("e" & lig).Value
    Sheets("Feuil1").Range("k" & dlt) = Sheets("DDN").Range("h" & lig).Value
    
    
    'NUMÉROTATION DES DOCUMENTS SELON LA CATÉGORIE CHOISIS
    If ComboBox1 = "ADMINISTRATION" Then Sheets("Feuil1").Range("a" & dlt) = "ADM"
    If ComboBox1 = "ADMINISTRATION ET FINANCE" Then Sheets("Feuil1").Range("a" & dlt) = "ADF"
    If ComboBox1 = "ACHAT" Then Sheets("Feuil1").Range("a" & dlt) = "ACH"
    If ComboBox1 = "INGÉNIERIE" Then Sheets("Feuil1").Range("a" & dlt) = "ING"
    If ComboBox1 = "CONSTRUCTION" Then Sheets("Feuil1").Range("a" & dlt) = "CON"
    If ComboBox1 = "QUALITÉ" Then Sheets("Feuil1").Range("a" & dlt) = "QUA"
    If ComboBox1 = "SANTÉ ET SÉCURITÉ" Then Sheets("Feuil1").Range("a" & dlt) = "SSE"
    
    
    
    If ComboBox2 = "Fichier de calcul" Then Sheets("Feuil1").Range("b" & dlt) = "FCA"
    If ComboBox2 = "Dessin" Then Sheets("Feuil1").Range("b" & dlt) = "DES"
    If ComboBox2 = "Devis" Then Sheets("Feuil1").Range("b" & dlt) = "DEV"
    If ComboBox2 = "Memo" Then Sheets("Feuil1").Range("b" & dlt) = "MEM"
    If ComboBox2 = "Registre" Then Sheets("Feuil1").Range("b" & dlt) = "REG"
    If ComboBox2 = "Rapport" Then Sheets("Feuil1").Range("b" & dlt) = "RAP"
    If ComboBox2 = "Liste de vérification" Then Sheets("Feuil1").Range("b" & dlt) = "LDV"
    If ComboBox2 = "Procédure" Then Sheets("Feuil1").Range("b" & dlt) = "PRO"
    If ComboBox2 = "Formulaire" Then Sheets("Feuil1").Range("b" & dlt) = "FOR"
    
    
    
      
    'FAIRE LE NO DE DOCUMENT FINALE
    
    'original
    'no = Sheets("feuil1").Range("h" & dlt).Value & "-" & Sheets("feuil1").Range("i" & dlt).Value & "-" & Sheets("feuil1").Range("j" & dlt).Value
    'Sheets("Feuil1").Range("e" & dlt) = Sheets("feuil1").Range("a" & dlt).Value & "-" & Sheets("feuil1").Range("b" & dlt).Value & "-" & no & "-" & Sheets("feuil1").Range("f" & dlt).Value & "-" & Sheets("feuil1").Range("l" & dlt).Value & "-" & Sheets("feuil1").Range("d" & dlt).Value
    
    'modifié
    no = Format(Sheets("feuil1").Range("H" & dlt).Value, "00") & Format(Sheets("feuil1").Range("I" & dlt).Value, "00") & Format(Sheets("feuil1").Range("I" & dlt).Value, "00")
    Sheets("Feuil1").Range("e" & dlt) = Sheets("feuil1").Range("a" & dlt).Value & "-" & Sheets("feuil1").Range("b" & dlt).Value & "-" & no & "-" & Format(Sheets("feuil1").Range("F" & dlt).Value, "00") & "-" & Format(Sheets("feuil1").Range("l" & dlt).Value, "000") & "-" & Sheets("feuil1").Range("d" & dlt).Value
    
    
    
    'UNE FOIS TERMINÉ FERMER LA FENÊTRE
    Unload UseForm1
    
    
    'AFFICHER UN MESSAGE QUI DONNE LE NUMÉRO DE DOCUMENT
     MsgBox "Veuillez indiqué le numéro suivant sur votre nouveau document:" & Sheets("Feuil1").Range("e" & dlt), vbInformation, "Confirmation d'identification"
            
    
        
    End If
    End Sub
    
    
    
    
    ' APRÈS AVOIR ENTRÉ UNE DATE, SI LE FORMAT N'EST PAS AAAA/MM/JJ, AFFICHER UNE ERREUR
    Private Sub TextBox3_AfterUpdate()
    On Error GoTo mesageerreur
    TextBox3 = Format(TextBox3, "short date")
    Exit Sub
    mesageerreur:
    MsgBox ("le format que vous avez indiqué n'est pas valide, le format doit être AAAA/MM/JJ")
    TextBox3 = Empty
    End Sub
    ' LA CASE DE DATE EST PRÉ AFFICHÉ AVEC AAAA/MM/JJ
    Private Sub TextBox3_Enter()
    If TextBox3 = "AAAA/MM/JJ" Then
    TextBox3 = ""
    End If
    End Sub
    'SI LA CASE DE DATE EST LAISSÉ VIDE, AFFICHER LE FORMAT AAAA/MM/JJ DANS LA CASE
    Private Sub TextBox3_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    If TextBox3 = "" Then
    TextBox3 = "AAAA/MM/JJ"
    End If
    End Sub
    ' LA DATE DOIT ÊTRE SEULEMENT EN CHIFFRE ENTRE 0 ET 9
    Private Sub TextBox3_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
    If Not ((KeyAscii > 46 And KeyAscii < 58)) Then
    KeyAscii = 0
    End If
    
    End Sub
    
    Private Sub textbox5_afterupdate()
    TextBox5.Value = Format(TextBox5.Value, "00")
    End Sub
    
    
    
    Private Sub UserForm_Initialize()
    
    TextBox3.Text = "AAAA/MM/JJ"
    'CATÉGORIE PRÉDÉFINIE DANS L'ITEM CATÉGORIE
    With ComboBox1
    .AddItem "ADMINISTRATION"
    .AddItem "ADMINISTRATION ET FINANCE"
    .AddItem "ACHAT"
    .AddItem "SANTÉ ET SÉCURITÉ"
    .AddItem "INGÉNIERIE"
    .AddItem "CONSTRUCTION"
    .AddItem "QUALITÉ"
    End With
    'DANS LA TYPE, LISTE DES ENTRÉES PRÉ DÉFINIE
    With ComboBox2
    .AddItem "Fichier de calcul"
    .AddItem "Dessin"
    .AddItem "Devis"
    .AddItem "Memo"
    .AddItem "Registre"
    .AddItem "Rapport"
    .AddItem "Liste de vérification"
    .AddItem "Procédure"
    .AddItem " Formulaire"
    
    
    
    End With
    
    End Sub
    ' COMBOBOX 3 DDN
    ' Remplir la combobox DDN avec la première colonne de la page DDN
    Private Sub Combobox3_enter()
    'ComboBox3.Clear
    Dim derniereligne As Long
    Dim liste2 As Variant
    
    derniereligne = Sheets("DDN").Cells(Rows.Count, "A").End(xlUp).Row
    liste2 = Sheets("DDN").Range("a7" & ":a" & derniereligne)
    ComboBox3.List = liste2
    
    End Sub
    
    Private Sub commandbutton2_Click()
    Sheets("DDN").Select
    End Sub
    


    EDIT : Ajout des balises de code
    0
    1. M-12 Messages postés 1349 Statut Membre 285
       
      Re,

      Ton userform s'ouvre bien par un bouton ou autre (double clic, clic droit, etc)
      donc tu as une ligne qui ressemble à
      Userformx.show

      tu rajoutes un " 0" (espace et zéro sans les guillemets)
      0
  3. PinkS13 Messages postés 8 Date d'inscription   Statut Membre Dernière intervention  
     
    Ca fonctionne merciiii
    0