Bonjour,

A nouveau je fais appel à votre savoir pour m'aider à terminer une routine.

j'ai pu adapter un code pour exporter une série de ligne à partir d'une zone, ma routine fonctionne.
Mais je n'arrive pas à trouver la meilleur façon d'exporter uniquement les lignes en fonction d'un champ d'une des colonnes

J'ai pensé à inclure un IF > End if mais je n'ai pas réussi

j'ai un onglet où se trouve les affections, Onglet [PARAMETRES].
Le champ que je veux tester non vide est ........... Range("PARAMETRES!Y14").Value



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
53
54
55
56
 
 
Sub ExportEcriture_FNP()
Dim Plage As Object, oL As Object, oC As Object
Dim Tmp$, Sep$, Ongl$
Dim Fichier$, Chemin$, CheminFiche$, Nlig&
Sheets(Range("PARAMETRES!Y13").Value).Select ' Non de l'onglet où se trouve les données à exporter
   With Application
      .ScreenUpdating = False
      .EnableEvents = False
      .Calculation = xlManual
   End With
Fichier = Range("PARAMETRES!Y14").Value & "." & Range("PARAMETRES!Y15").Value ' 1ère colonne à exporter dernière colonne à exporter
'Fichier = "Fichier_Pv_syst" & ".csv"
Set rep = Application.FileDialog(msoFileDialogFolderPicker)
    If rep.Show <> 0 Then
        Chemin = rep.SelectedItems(1) & "\"
    Else
        MsgBox "Vous n'avez Choisi aucun Dossier", , "Manque de Choix de Dossier": Exit Sub
    End If
    Application.ScreenUpdating = False
CheminFiche = Chemin & Fichier
 
 
 
 
Nlig = Cells(Rows.Count, 1).End(xlUp).Row
Sep = vbTab ' ";"
   Set Plage = Range(Range("PARAMETRES!Y16").Value & 4 & ":" & Range("PARAMETRES!Y17").Value & Nlig) '1ère ligne à exporter dernière ligne à exporter
      Open CheminFiche For Output As #1
 
 
 
         For Each oL In Plage.Rows
 
                ' écriture exportée
             Tmp = ""
             For Each oC In oL.Cells
                 Tmp = Tmp & CStr(oC.Text) & Sep
             Next
                 Print #1, Left(Tmp, Len(Tmp) - 1)
 
 
         Next
 
 
      Close
   Set Plage = Nothing
MsgBox "Le fichier CSV a est créé ", vbInformation, "Admin"
    With Application
       .ScreenUpdating = True
       .Calculation = xlCalculationAutomatic
       .EnableEvents = True
       .Goto [A1], True
    End With
End Sub
Merci d'avance
bon dimanche

Christian