Bonjour, quand mon code s'exécute OK mais quand je ferme le classeur et que je l'ouvre un message d'erreur apparait et me répare ma feuille en question.
je ne trouve pas d'où vient le problème . Voici mon code:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
Private Sub Worksheet_Activate()
    Dim cnx As New ADODB.Connection
    Dim cmd As New ADODB.Command
    Dim rst As New ADODB.Recordset
    Dim resultat As Variant
    Dim Rcompte As Integer 'Nombre d'enregistrement recordset
 
 
'Création de la connexion
    cnx.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=********;Persist Security Info=False;"
    Set cmd.ActiveConnection = cnx
 
'Création de la commande
    cmd.CommandType = adCmdText
    cmd.CommandText = "Select * From R_FormationExcel"
 
'Execution de la commande
    rst.CursorLocation = adUseClient
    rst.Open cmd, , adOpenStatic, adLockBatchOptimistic
 
'Compte le nombre d'enregistrement
    Rcompte = rst.RecordCount
    Debug.Print (Rcompte)
'Parcour des enregistrement
    Do Until rst.EOF
    resultat = resultat & rst("LibelleFormation") & ","
    rst.MoveNext
    'Debug.Print resultat
    Loop
    rst.MoveFirst
 
    'Range("LibelleFormationAjoutFormation") = ""
    With Range("LibelleFormationAjoutFormation").Validation
        .Delete
        .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
        xlBetween, Formula1:=resultat
        .IgnoreBlank = True
        .InCellDropdown = True
        .InputTitle = ""
        .ErrorTitle = ""
        .InputMessage = ""
        .ErrorMessage = ""
        .ShowInput = True
        .ShowError = False
    End With
 
cnx.Close
Set cnx = Nothing
Set rst = Nothing
Set cmd = Nothing
resultat = ""
End Sub
Merci pour votre aide