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
| Private Sub nouvellefeuille_Click()
Dim chemin As String, vname As String
Dim plage As Range
Dim dlig As Byte
Dim code As Integer
' nouvellefacturedevis Macro
code = WorksheetFunction.Match(ActiveSheet.Range("c6"), _
Sheets("facturation").Range("c2:c" & Sheets("facturation").Range("c65536").End(xlUp).Row), 0) + 3
Sheets("facturation").Copy
ActiveSheet.Shapes("commandbutton1").Select
Selection.Delete
With Cells
.Copy
.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone
End With
Range("A1").Select
Application.CutCopyMode = False
Select Case UCase(Range("D2"))
Case Is = "FACTURE", "FACTURE SAV", "FACTURE D'ACOMPTE": chemin = "C:\facture\facture\"
Case Else: chemin = "C:\facture\devis\"
End Select
vname = Range("c17") & "" & Range("I5") & ".xls"
With ActiveWorkbook
.SaveAs Filename:=chemin & vname
.Close
End With
With Sheets("facturation")
dlig = .Range("C19").End(xlDown)(1).Row
If dlig > 20 Then
Set plage = .Range("C20:B" & .Range("C20").End(xlDown)(1).Row - 1)
plage.EntireRow.Delete
End If
.Range("c19:p20").ClearContents
.Range("I5:I8").ClearContents
'incrémentation
Select Case UCase(Range("D2"))
Case Is = "FACTURE"
Range("B9") = Range("B9") + 1
Case Is = "DEVIS"
Range("B8") = Range("B8") + 1
Case Is = "FACTURE D'ACOMPTE"
Range("B10") = Range("B10") + 1
Case Is = "FACTURE SAV"
Range("B11") = Range("B11") + 1
End Select
End With
End Sub |