pouvez vous tester ce code pour cela vous devez créer un dossier gestion a la racine de C:
J'ai joint un fichier excel
voici mon code![]()
Sur une plage de données (a chaque impressions renouvellées )Ce que je cherche a faire est assez simple,
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 Sub Enregistre_et_Nouveau() Dim nom As Workbook Dim chemin As String, extension As String, nomfichier As String With Application .ScreenUpdating = False .EnableEvents = False End With ThisWorkbook.ActiveSheet.Copy ActiveSheet.UsedRange.Activate With Selection .Copy .PasteSpecial Paste:=xlValues .Validation.Delete End With extension = ".xls" If ActiveSheet.Name = "ticket" Then chemin = "C:\Gestion\" nomfichier = ActiveSheet.Range("D21") & ("-") & Format(Now(), "dd-mm-yy") & extension End If With ActiveWorkbook .SaveAs Filename:=chemin & nomfichier .Close End With With Application .ScreenUpdating = True .EnableEvents = True Dim c As Integer With Application .ScreenUpdating = False .EnableEvents = False End With End With ActiveSheet.PrintOut Copies:=1 With ThisWorkbook With ActiveSheet c = .Range("D21").Value .Range("D21").Value = c + 1 If .Name = "ticket" Then .Range("A7:D16").ClearContents End If End With .Save End With With Application .ScreenUpdating = False .EnableEvents = False End With End Subimprimer (ça marche) effacer certaines données ( ça marche aussi) Là ou ça se complique c'est l'enregistrement , je voudrais enregistrer la plage de cellules B6 à D22 sur une autre feuilles excel dans le même classeur, et que chaques enregistrement soit en dessous du précédent toujour sur la même feuille. Ce qui ce passe avec mon code actuel, il me crée un nouveau classeur a chaque nouveau ticket et m'enregistre la feuille complète macro comprise. merci de votre aide
Partager