KTM
XLDnaute Impliqué
Bonjour chers tous
Dans mon fichier joint ; je voudrais extraire et copier dans un nouveau classeur en supprimant les lignes dont le total est 0
j'ai élaboré une macro mais certains points ne fonctionnent pas bien
1- La suppression des lignes à total =0
2- La mise en page dans le nouveau classeur
Merci de bien vouloir corriger mon code ou me proposer mieux.
	
	
	
	
	
		
	
		
			
		
		
	
				
			Dans mon fichier joint ; je voudrais extraire et copier dans un nouveau classeur en supprimant les lignes dont le total est 0
j'ai élaboré une macro mais certains points ne fonctionnent pas bien
1- La suppression des lignes à total =0
2- La mise en page dans le nouveau classeur
Merci de bien vouloir corriger mon code ou me proposer mieux.
		VB:
	
	
	Sub COPIE()
Application.ScreenUpdating = False
Dim chemin As String
Dim fichier As String, f As Worksheet,cel as range,Ls as long
chemin = ThisWorkbook.Path & "\fact\"
If Dir(chemin, vbDirectory) = "" Then MkDir chemin
    Application.ScreenUpdating = False
    Set f = ActiveWorkbook.Worksheets("fiche")
    fichier = "Extrait"
    With f
    .UsedRange.Copy
    End With
    Application.ScreenUpdating = False
    Application.EnableEvents = False
    Workbooks.Add (xlWBATWorksheet)
    Application.EnableEvents = True
    With ActiveWorkbook
    Application.ScreenUpdating = False
        With .Worksheets(1).Cells(1)
            .PasteSpecial Paste:=xlPasteValues
            .PasteSpecial Paste:=xlPasteFormats
        End With
        Application.CutCopyMode = False
        ActiveWindow.DisplayGridlines = False
    Application.ScreenUpdating = False
    With .Sheets(1)
    Application.ScreenUpdating = False
    For Each cel In .Range("E5:E26")
    If cel.Value = 0 Then cel.Rows.Delete
    Next cel
    Ls = Range("A" & Rows.Count).End(xlUp).Row + 2
    .Columns("A:E").AutoFit
    .PageSetup.PrintArea = .Range("$A$1:$E$" & Ls).Address
    .PageSetup.Orientation = xlPortrait
    .PageSetup.FitToPagesTall = 1
    .PageSetup.FitToPagesWide = 1
    .PageSetup.RightFooter = "&P de &N"
    .PageSetup.LeftMargin = Application.InchesToPoints(0.118110236220472)
    .PageSetup.RightMargin = Application.InchesToPoints(0.118110236220472)
    End With
                     Application.ScreenUpdating = False
                     Application.DisplayAlerts = False
.SaveAs chemin & fichier, 51
.Close
End With
Set f = Nothing
End Sub