Découper fichier excel en plusieurs fichiers VBA
Titi83600
Messages postés
5
Date d'inscription
Statut
Membre
Dernière intervention
-
f894009 Messages postés 17277 Date d'inscription Statut Membre Dernière intervention -
f894009 Messages postés 17277 Date d'inscription Statut Membre Dernière intervention -
Bonjour,
j'ai besoin d'aide pour découper un fichier excel en plusieurs fichiers avec comme filtre la colonne C et il n'y a pas d'en-tête de colonne.
Mon code fonctionne bien mais il récupère systématiquement la première ligne pour un en-tête alors que je ne le souhaite pas, pouvez-vous m'aider svp. Merci d'avance
Option Explicit
Sub creation_fichiers()
Dim i As Integer
Dim sh, Dlg, plg
Application.ScreenUpdating = False
Set sh = Sheets(1)
Dlg = sh.Cells(Rows.Count, 1).End(xlUp).Row
Set plg = sh.Range("A1:G" & Dlg)
sh.Range("C1:C" & Dlg).Copy sh.[K1]
sh.[K:K].RemoveDuplicates Columns:=Array(1), Header:=xlNo
sh.[L1] = sh.[C1]
For i = 2 To sh.Cells(Rows.Count, "K").End(xlUp).Row
Workbooks.Add
sh.[L2] = sh.Range("K" & i)
plg.AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=sh.Range("L1:L2"), CopyToRange:=ActiveWorkbook.Sheets(1).Range("A1:G1")
Columns("A:G").Columns.AutoFit
If Dir(ThisWorkbook.Path & "SU_ " & Left(sh.Range("K" & i), 10) & ".don") = "" Then ActiveWorkbook.SaveAs Filename:=ActiveWorkbook.Path & "SU_ " & Left(sh.Range("K" & i), 10) & ".don", FileFormat:=xlCSV
ActiveWorkbook.Close False
Next i
sh.[K:L].ClearContents
End Sub
j'ai besoin d'aide pour découper un fichier excel en plusieurs fichiers avec comme filtre la colonne C et il n'y a pas d'en-tête de colonne.
Mon code fonctionne bien mais il récupère systématiquement la première ligne pour un en-tête alors que je ne le souhaite pas, pouvez-vous m'aider svp. Merci d'avance
Option Explicit
Sub creation_fichiers()
Dim i As Integer
Dim sh, Dlg, plg
Application.ScreenUpdating = False
Set sh = Sheets(1)
Dlg = sh.Cells(Rows.Count, 1).End(xlUp).Row
Set plg = sh.Range("A1:G" & Dlg)
sh.Range("C1:C" & Dlg).Copy sh.[K1]
sh.[K:K].RemoveDuplicates Columns:=Array(1), Header:=xlNo
sh.[L1] = sh.[C1]
For i = 2 To sh.Cells(Rows.Count, "K").End(xlUp).Row
Workbooks.Add
sh.[L2] = sh.Range("K" & i)
plg.AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=sh.Range("L1:L2"), CopyToRange:=ActiveWorkbook.Sheets(1).Range("A1:G1")
Columns("A:G").Columns.AutoFit
If Dir(ThisWorkbook.Path & "SU_ " & Left(sh.Range("K" & i), 10) & ".don") = "" Then ActiveWorkbook.SaveAs Filename:=ActiveWorkbook.Path & "SU_ " & Left(sh.Range("K" & i), 10) & ".don", FileFormat:=xlCSV
ActiveWorkbook.Close False
Next i
sh.[K:L].ClearContents
End Sub
A voir également:
- Macro pour découper un fichier excel en plusieurs fichiers
- Fichier bin - Guide
- Fichier epub - Guide
- Comment réduire la taille d'un fichier - Guide
- Fichier rar - Guide
- Telecharger macro convertir chiffre en lettre excel - Télécharger - Tableur
3 réponses
Bonjour,
Pouvez mettre un fichier a dispo
Pour transmettre un fichier,
Veillez a ce qu'il n'y ait PAS DE DONNEES CONFIDENTIELLES
il faut passer par un site de pièce jointe tel que cjoint.com
Allez sur ce site : https://www.cjoint.com/
Clic sur parcourir,
Cherche ton fichier,
clic sur ouvrir,
Clic sur "Créer le lien cjoint",
Copier le lien,
Revenir ici le coller dans une réponse...
ou
'mon partage
https://mon-partage.fr/
Pouvez mettre un fichier a dispo
Pour transmettre un fichier,
Veillez a ce qu'il n'y ait PAS DE DONNEES CONFIDENTIELLES
il faut passer par un site de pièce jointe tel que cjoint.com
Allez sur ce site : https://www.cjoint.com/
Clic sur parcourir,
Cherche ton fichier,
clic sur ouvrir,
Clic sur "Créer le lien cjoint",
Copier le lien,
Revenir ici le coller dans une réponse...
ou
'mon partage
https://mon-partage.fr/