XL 2019 Erreur d’exécution à l'ouverture de l'userform

Tempus

XLDnaute Junior
Bonjour à tous,

Je sollicite l'aide du forum, j'ai une erreur d’exécution à l'ouverture de l'userform.

Sur le net certain parle d'une variable qui serait mal déclarée, mais je n'arrive pas à trouver


Mon fichier est en pièce jointe,

Merci à vous.
 

Pièces jointes

  • tempus (1).xlsm
    59.5 KB · Affichages: 11
Solution
Bonsoir job75,

Merci à vous, c'est parfait l'userform se charge.

Pouvez vous m'aider j'ai deux autres problèmes.

Le premier, lorsque je click sur le bouton modifier dans la listbox, cela ferme Excel , le code vba du bouton est ci-dessous, et il y a encore une erreur d’exécution avec le bouton supprimer, la capture d’écran de cette erreur est en pièce jointe.

Merci encore.

VB:
Private Sub CommandButton3_Click()

Dim lig As Integer
Dim Cible As Integer
If ListBox1.ListIndex = -1 Then Exit Sub
lig = ListBox1.ListIndex + 2

    With Worksheets("BD")
        .Columns("A:K").Rows(lig).ClearContents
        .Cells(lig, 1) = CDate(TextBox1)
        .Cells(lig, 2) = TextBox9.Value
        .Cells(lig, 3) = TextBox10.Value...

job75

XLDnaute Barbatruc
Bonsoir Tempus,

Ça se passe dans la macro Charge_Listbox1 de UserForm2, remplacez :
VB:
ListBox1.List(I, J) = Format(.List(I, J), Rng.Columns(J + 1).NumberFormat)
par :
VB:
ListBox1.List(I, J) = Format(.List(I, J), Rng(I, J + 1).NumberFormat)
Le bug venait du fait que les cellules de la colonne étudiée ne sont pas toutes au même format.

A+
 

Tempus

XLDnaute Junior
Bonsoir job75,

Merci à vous, c'est parfait l'userform se charge.

Pouvez vous m'aider j'ai deux autres problèmes.

Le premier, lorsque je click sur le bouton modifier dans la listbox, cela ferme Excel , le code vba du bouton est ci-dessous, et il y a encore une erreur d’exécution avec le bouton supprimer, la capture d’écran de cette erreur est en pièce jointe.

Merci encore.

VB:
Private Sub CommandButton3_Click()

Dim lig As Integer
Dim Cible As Integer
If ListBox1.ListIndex = -1 Then Exit Sub
lig = ListBox1.ListIndex + 2

    With Worksheets("BD")
        .Columns("A:K").Rows(lig).ClearContents
        .Cells(lig, 1) = CDate(TextBox1)
        .Cells(lig, 2) = TextBox9.Value
        .Cells(lig, 3) = TextBox10.Value
        .Cells(lig, 4) = TextBox2.Value
        .Cells(lig, 5) = TextBox3.Value
        .Cells(lig, 6) = TextBox4.Value
        .Cells(lig, 7) = TextBox5.Value
    
        .Cells(lig, 8).FormulaLocal = "=" & _
            .Cells(lig, 7).Address(False) & "/" & .Cells(lig, 6).Address(False)
        .Cells(lig, 9).FormulaLocal = "=" & _
            .Cells(lig, 5).Address(False) & "/" & .Cells(lig, 8).Address(False)
    
        .Cells(lig, 10) = TextBox8.Value
        .Cells(lig, 11) = TextBox13.Value
        
       ' on redéfinit la plage des MFC
        For Each Mfc In .Cells.FormatConditions
            Mfc.ModifyAppliesToRange .Range("$I2:$I" & .Rows(.Rows.Count).End(xlUp).Row)
        Next
      
    End With
    Charge_Listbox1

End Sub
 

Pièces jointes

  • tempus (1) (1).xlsm
    59.8 KB · Affichages: 4
  • bouton supprimer erreur d'execution 424 objet requis.PNG
    bouton supprimer erreur d'execution 424 objet requis.PNG
    56.2 KB · Affichages: 8

cp4

XLDnaute Barbatruc
Bonsoir job75,

Merci à vous, c'est parfait l'userform se charge.

Pouvez vous m'aider j'ai deux autres problèmes.

Le premier, lorsque je click sur le bouton modifier dans la listbox, cela ferme Excel , le code vba du bouton est ci-dessous, et il y a encore une erreur d’exécution avec le bouton supprimer, la capture d’écran de cette erreur est en pièce jointe.

Merci encore.

VB:
Private Sub CommandButton3_Click()

Dim lig As Integer
Dim Cible As Integer
If ListBox1.ListIndex = -1 Then Exit Sub
lig = ListBox1.ListIndex + 2

    With Worksheets("BD")
        .Columns("A:K").Rows(lig).ClearContents
        .Cells(lig, 1) = CDate(TextBox1)
        .Cells(lig, 2) = TextBox9.Value
        .Cells(lig, 3) = TextBox10.Value
        .Cells(lig, 4) = TextBox2.Value
        .Cells(lig, 5) = TextBox3.Value
        .Cells(lig, 6) = TextBox4.Value
        .Cells(lig, 7) = TextBox5.Value
   
        .Cells(lig, 8).FormulaLocal = "=" & _
            .Cells(lig, 7).Address(False) & "/" & .Cells(lig, 6).Address(False)
        .Cells(lig, 9).FormulaLocal = "=" & _
            .Cells(lig, 5).Address(False) & "/" & .Cells(lig, 8).Address(False)
   
        .Cells(lig, 10) = TextBox8.Value
        .Cells(lig, 11) = TextBox13.Value
       
       ' on redéfinit la plage des MFC
        For Each Mfc In .Cells.FormatConditions
            Mfc.ModifyAppliesToRange .Range("$I2:$I" & .Rows(.Rows.Count).End(xlUp).Row)
        Next
     
    End With
    Charge_Listbox1

End Sub
Bonsoir,
VB:
Feuil1.Rows(LigneSelectionnée).Delete 'plantage
Feuil1 n'existe pas d'où l'objet manquant.

Bonne soirée.
 

Statistiques des forums

Discussions
312 203
Messages
2 086 184
Membres
103 152
dernier inscrit
Karibu