Erreur d'éxécution '13' incompatibilité de type

Bonjour le forum,

j'ai un message d'erreur "erreur d'éxécution '13' incompatibilité de type lors que je veux ouvrir mon formulaire.

A noter que ce dysfonctionnement apparaît lorsque que ma base de donnée est vidé de toutes données.

QQ 1 peut il m'aider à résoudre ce problème ?

merci et bonne soirée à vous

Option Explicit
Dim Ws As Worksheet
Public nouveau As Boolean

'suppression d'un intervenant'

Private Sub CommandButton4_Click()
If MsgBox("Confirmez-vous la suppression de cet intervenant ?", vbYesNo, "Demande de confirmation d'ajout") = vbYes Then

Rows([a3:a65536].Find(ComboBox1.Value).Row).EntireRow.Delete

Unload Me
UserForm1.Show
Else
'rien
End If

End Sub

'Pour le formulaire
Private Sub UserForm_Initialize()

    Dim J As Long
    Dim I As Long

            Set Ws = Sheets("bdd")
            With Me.ComboBox1
            For J = 3 To Ws.Range("A" & Rows.Count).End(xlUp).Row
            .AddItem Ws.Range("A" & J)

        Next J

'incrémente un nouveau numéro à l'ouverture du useform

            nouveau = True

            I = Feuil1.Cells(Application.Rows.Count, "A").End(xlUp).Row

        If nouveau = True Then ComboBox1 = Feuil1.Range("A" & I).Value + 1

    End With

End Sub

'Pour la liste déroulante Code client récupère les infos

Private Sub ComboBox1_Change()

    Dim Ligne As Long
    Dim I As Integer
    Dim J As Integer
    Dim Tbl

        If Me.ComboBox1.ListIndex = -1 Then Exit Sub
        Ligne = Me.ComboBox1.ListIndex + 3

        For I = 1 To 8

        Me.Controls("TextBox" & I) = Ws.Cells(Ligne, I + 1)

    Next I

        SelectListBox ListBox1, Ws.Cells(Ligne, 10)
        SelectListBox ListBox2, Ws.Cells(Ligne, 11)

End Sub

Sub SelectListBox(Lst As MSForms.ListBox, Chaine As String)

    Dim Tbl
    Dim I As Integer
    Dim J As Integer

'dé-sélectionne tout
        For I = 0 To Lst.ListCount - 1: Lst.Selected(I) = False: Next I

'splite sur la chaine
        Tbl = Split(Chaine, ";")

'boucle sur le tableau et la ListBox afin de sélectionner les choix
        For I = 0 To UBound(Tbl) - 1

        For J = 0 To Lst.ListCount - 1

        If Lst.List(J) = Tbl(I) Then Lst.Selected(J) = True

    Next J

Next I

End Sub
'ajouter le Nouvel intervenant à ma bdd
Private Sub CommandButton1_Click()

    Dim L As Long

        If MsgBox("Confirmez-vous l'insertion de ce nouveau contact ?", vbYesNo, "Demande de confirmation d'ajout") = vbNo Then Exit Sub

        L = Sheets("bdd").Range("A" & Rows.Count).End(xlUp).Row + 1 'Pour placer le nouvel enregistrement ? la premi?re ligne de tableau non vide

    Inscrire L

End Sub

'Pour le bouton Modifier

Private Sub CommandButton2_Click()

    Dim Ws As Worksheet
    Dim L As Long
    Dim C As Integer

        If MsgBox("Confirmez-vous la modification de ce contact ?", vbYesNo, "Demande de confirmation de modification") = vbNo Then Exit Sub
        If Me.ComboBox1.ListIndex = -1 Then Exit Sub

        L = Me.ComboBox1.ListIndex + 3

        Inscrire L

End Sub

Sub Inscrire(L As Long)

    Dim Ws As Worksheet
    Dim I As Integer
    Dim mobilite As String
    Dim domaine As String
    Dim Tbl

        Range("A" & L).Value = CDbl(ComboBox1)
        Range("B" & L).Value = TextBox1
        Range("C" & L).Value = TextBox2
        Range("D" & L).Value = TextBox3
        Range("E" & L).Value = TextBox4
        Range("F" & L).Value = TextBox5
        Range("G" & L).Value = TextBox6
        Range("H" & L).Value = TextBox7
        Range("I" & L).Value = TextBox8

        Set Ws = Worksheets("bdd")

 'récup des choix
        For I = 0 To Me.ListBox1.ListCount - 1

        If Me.ListBox1.Selected(I) Then domaine = domaine & Me.ListBox1.List(I) & ";"

    Next

  'splite dans un tableau...
        Tbl = Split(domaine, ";")

  'et dispatche dans les colonnes
    With Ws

        .Range("j" & L).Value = domaine
        .Range(.Cells(L, 12), .Cells(L, 12 + UBound(Tbl))).Value = Tbl

    End With

        For I = 0 To Me.ListBox2.ListCount - 1

        If Me.ListBox2.Selected(I) Then mobilite = mobilite & Me.ListBox2.List(I) & ";"

    Next I

        Tbl = Split(mobilite, ";")

    With Ws

        .Range("K" & L).Value = mobilite
        .Range(.Cells(L, 15), .Cells(L, 15 + UBound(Tbl))).Value = Tbl

    End With

        Unload Me
        UserForm1.Show

End Sub
'Pour le bouton Quitter
Private Sub CommandButton3_Click()
    Unload Me
End Sub

'vérifier le choix de ma listbox mobilité

Private Sub CommandButton6_Click()
      Dim Msg As String
      Dim I As Integer
      For I = 0 To Me.ListBox2.ListCount - 1
          If Me.ListBox2.Selected(I) Then
              Msg = Msg & Me.ListBox2.List(I) & vbNewLine
          End If
      Next I
      MsgBox Msg
End Sub

'vérifier le choix de ma listbox domaine

Private Sub CommandButton5_Click()
Dim Msg As String
      Dim I As Integer
      For I = 0 To Me.ListBox1.ListCount - 1
          If Me.ListBox1.Selected(I) Then
              Msg = Msg & Me.ListBox1.List(I) & vbNewLine
          End If
      Next I
      MsgBox Msg
End Sub

'limite le choix multiselect de la listbox1

Private Sub ListBox1_change()

  Static nb As Integer
  Dim choisi As Integer, max As Integer
  max = 3
  choisi = ListBox1.ListIndex
  If ListBox1.Selected(choisi) = False Then nb = nb - 1: Exit Sub
  If nb >= max Then ListBox1.Selected(choisi) = False
  nb = nb + 1
End Sub

'limite le choix multiselect de la listbox1

Private Sub ListBox2_change()

  Static nb As Integer
  Dim choisi As Integer, max As Integer
  max = 20
  choisi = ListBox2.ListIndex
  If ListBox2.Selected(choisi) = False Then nb = nb - 1: Exit Sub
  If nb >= max Then ListBox2.Selected(choisi) = False
  nb = nb + 1
End Sub
Xavier22 a écrit :

QQ 1 peut il m'aider à résoudre ce problème ?

Bonjour,

Sans le classeur KIVABIEN avec, ça m'étonnerait !

A+

bonjour,

ci-joint

Bonsoir,

regarde lors de l'ouverture

Sub ouverture()
UserForm1.Show vModeless

End Sub

erreur 13 également

Sub ouverture()

UserForm1.Show vodeless

End Sub

crdlt,

André

Bonsoir,

merci pour le retour, mais ce n'est pas que ça

re,

en bidouillant juste pour que tu puisses re-travailller dessus

Sub ouverture()
If Sheets("bdd").Range("A3").Value = Empty Then
Sheets("bdd").Range("A3") = "1"
Sheets("bdd").Range("A3").Select

Else
UserForm1.Show vbModeless
End If
End Sub

Merci Andre,

c'est très gentil

re,

j'ai remarqué sur l'USF, tu avais un chiffre 2 sur la combobox 1

si la combobox est vide je pense que c'est du à cela

a quel niveau tu vois ça andre

re,

oui c'est normal, si tu clics sur Formulaire de saisie de l'USF la combo 1 se met sur 2, ce qui est normale puisque dans la feuille BD le chiffre 1 est sur la colonne A 'matricule'

d'ou au bidouillage de l'ouverture de l'USF qui ne voulait plus s'ouvrir

EDIT : je pense qu'il y a une modification à effectuer sur la combo si vide etc.

Sub ouverture()
If Sheets("bdd").Range("A3").Value = Empty Then
Sheets("bdd").Range("A3") = "1"
Sheets("bdd").Range("A3").Select

Else
UserForm1.Show vbModeless
Sheets("bdd").Range("A3").Value = ""
Sheets("bdd").Range("A3").Select
End If
End Sub

çà t'effaces le chiffre 1, tout en sachant que tu peux modifier l'immatricule 1 etc.

à tester lorsque c'est vide

crdlt,

André

doit être tard te suis pas

re,

je disais qu'il faut tester maintenant pour voir lorsque tu supprimes sur la BDD si un message d'incompatibilité arrive

effectue une sauvegarde avant.

je test et te dis en tout cas merci bcp pour le temps passé

Tu peux essayer çà aussi Xavier,

Private Sub UserForm_Initialize()

......

    If nouveau = True Then
        If I = 2 Then ComboBox1 = 1 Else ComboBox1 = Feuil1.Range("A" & I).Value + 1
    End If

Fichier en PJ

Cordialement

bonjour,

Modifier la macro comme suit :

'Pour le formulaire

Private Sub UserForm_Initialize()
Dim J As Long
Dim i As Long
   Set Ws = Sheets("bdd")
   With Me.ComboBox1
      For J = 3 To Ws.Range("A" & Rows.Count).End(xlUp).Row
      .AddItem Ws.Range("A" & J)
      Next J
   End With
'incrémente un nouveau numéro à l'ouverture du useform
nouveau = True
i = Feuil1.Cells(Application.Rows.Count, "A").End(xlUp).Row + 1
If nouveau = True Then ComboBox1 = WorksheetFunction.max(Feuil1.Columns(1)) + 1
End Sub

A+

Milles merci à vous tous pour vos différentes solutions et votre disponibilité. problème résolu

@ très bientôt

Xavier

Rechercher des sujets similaires à "erreur execution incompatibilite type"