Mise en page dans une macro avec filtres
goldy07
Messages postés
4
Date d'inscription
Statut
Membre
Dernière intervention
-
Bilow Messages postés 1014 Date d'inscription Statut Membre Dernière intervention -
Bilow Messages postés 1014 Date d'inscription Statut Membre Dernière intervention -
Bonjour,
Je crains que mes compétences ne soient pas suffisante pour mon soucis.
j'ai une macro VBA qui me permets de récupérer des données sur la première feuille d'un fichier, et de les répartir sur trois autres feuilles selon des filtres instaurés; cependant elle ne tient aucun compte de la mise en page, en particulier des encadrement, ce qui pose un problème pour le ficher.
La macro de base est la suivante :
Sub MAJ_TX()
'
' MAJ_TX Macro
'
Application.ScreenUpdating = False
Dim i, j, k, l As Integer
Dim P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11 As Variant (P sont mes colonnes)
j = 3
k = 3
Sheets(2).Select
ActiveSheet.Unprotect password:="protection1"
Sheets(3).Select
ActiveSheet.Unprotect password:="protection2"
Sheets(4).Select
ActiveSheet.Unprotect password:="protection3"
For i = 3 To 500
Sheets(1).Select
Cells(i, 1).Select
P1 = ActiveCell.Value
Cells(i, 2).Select
P2 = ActiveCell.Value
Cells(i, 3).Select
P3 = ActiveCell.Value
Cells(i, 4).Select
P4 = ActiveCell.Value
Cells(i, 5).Select
P5 = ActiveCell.Value
Cells(i, 6).Select
P6 = ActiveCell.Value
Cells(i, 7).Select
P7 = ActiveCell.Value
Cells(i, 8).Select
P8 = ActiveCell.Value
Cells(i, 9).Select
P9 = ActiveCell.Value
Cells(i, 10).Select
P10 = ActiveCell.Value
Cells(i, 11).Select
P11 = ActiveCell.Value
Sheets(2).Select
l = i
Cells(l, 1).Select
ActiveCell.Value = P1
Cells(l, 2).Select
ActiveCell.Value = P2
Cells(l, 3).Select
ActiveCell.Value = P3
Cells(l, 4).Select
ActiveCell.Value = P4
Cells(l, 5).Select
ActiveCell.Value = P11
If P3 = "A" Or P7 <> 0 Or P9 <> 0 Then
Sheets(3).Select
Cells(j, 1).Select
ActiveCell.Value = P1
Cells(j, 2).Select
ActiveCell.Value = P2
Cells(j, 3).Select
ActiveCell.Value = P3
Cells(j, 4).Select
ActiveCell.Value = P4
Cells(j, 5).Select
ActiveCell.Value = P5
Cells(j, 6).Select
ActiveCell.Value = P6
Cells(j, 7).Select
ActiveCell.Value = P7
Cells(j, 8).Select
ActiveCell.Value = P9
Cells(j, 9).Select
ActiveCell.Value = P11
j = j + 1
End If
If P7 <> 0 Or P9 <> 0 Then
Sheets(4).Select
Cells(k, 1).Select
ActiveCell.Value = P1
Cells(k, 2).Select
ActiveCell.Value = P5
Cells(k, 3).Select
ActiveCell.Value = P7
Cells(k, 4).Select
ActiveCell.Value = P8
Cells(k, 5).Select
ActiveCell.Value = P9
Cells(k, 6).Select
ActiveCell.Value = P10
Cells(k, 7).Select
ActiveCell.Value = P11
k = k + 1
End If
Next i
Sheets(2).Select
For i = l + 1 To 500
Cells(i, 1).Select
ActiveCell.Value = Null
Cells(i, 2).Select
ActiveCell.Value = Null
Cells(i, 3).Select
ActiveCell.Value = Null
Cells(i, 4).Select
ActiveCell.Value = Null
Cells(i, 5).Select
ActiveCell.Value = Null
Next i
ActiveSheet.Protect DrawingObjects:=True, contents:=True, Scenarios:=True, password:="protection1"
Sheets(3).Select
For i = j To 500
Cells(i, 1).Select
ActiveCell.Value = Null
Cells(i, 2).Select
ActiveCell.Value = Null
Cells(i, 3).Select
ActiveCell.Value = Null
Cells(i, 4).Select
ActiveCell.Value = Null
Cells(i, 5).Select
ActiveCell.Value = Null
Cells(i, 6).Select
ActiveCell.Value = Null
Cells(i, 7).Select
ActiveCell.Value = Null
Cells(i, 8).Select
ActiveCell.Value = Null
Cells(i, 9).Select
ActiveCell.Value = Null
Next i
ActiveSheet.Protect DrawingObjects:=True, contents:=True, Scenarios:=True, password:="protection2"
Sheets(4).Select
For i = k To 500
Cells(i, 1).Select
ActiveCell.Value = Null
Cells(i, 2).Select
ActiveCell.Value = Null
Cells(i, 3).Select
ActiveCell.Value = Null
Cells(i, 4).Select
ActiveCell.Value = Null
Cells(i, 5).Select
ActiveCell.Value = Null
Cells(i, 6).Select
ActiveCell.Value = Null
Cells(i, 7).Select
ActiveCell.Value = Null
Next i
ActiveSheet.Protect DrawingObjects:=True, contents:=True, Scenarios:=True, password:="protection3"
'
End Sub
Sauriez vous comment je pourrais y intégrer un élément me conservant la mise en page ?
D'avance merci.
Je crains que mes compétences ne soient pas suffisante pour mon soucis.
j'ai une macro VBA qui me permets de récupérer des données sur la première feuille d'un fichier, et de les répartir sur trois autres feuilles selon des filtres instaurés; cependant elle ne tient aucun compte de la mise en page, en particulier des encadrement, ce qui pose un problème pour le ficher.
La macro de base est la suivante :
Sub MAJ_TX()
'
' MAJ_TX Macro
'
Application.ScreenUpdating = False
Dim i, j, k, l As Integer
Dim P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11 As Variant (P sont mes colonnes)
j = 3
k = 3
Sheets(2).Select
ActiveSheet.Unprotect password:="protection1"
Sheets(3).Select
ActiveSheet.Unprotect password:="protection2"
Sheets(4).Select
ActiveSheet.Unprotect password:="protection3"
For i = 3 To 500
Sheets(1).Select
Cells(i, 1).Select
P1 = ActiveCell.Value
Cells(i, 2).Select
P2 = ActiveCell.Value
Cells(i, 3).Select
P3 = ActiveCell.Value
Cells(i, 4).Select
P4 = ActiveCell.Value
Cells(i, 5).Select
P5 = ActiveCell.Value
Cells(i, 6).Select
P6 = ActiveCell.Value
Cells(i, 7).Select
P7 = ActiveCell.Value
Cells(i, 8).Select
P8 = ActiveCell.Value
Cells(i, 9).Select
P9 = ActiveCell.Value
Cells(i, 10).Select
P10 = ActiveCell.Value
Cells(i, 11).Select
P11 = ActiveCell.Value
Sheets(2).Select
l = i
Cells(l, 1).Select
ActiveCell.Value = P1
Cells(l, 2).Select
ActiveCell.Value = P2
Cells(l, 3).Select
ActiveCell.Value = P3
Cells(l, 4).Select
ActiveCell.Value = P4
Cells(l, 5).Select
ActiveCell.Value = P11
If P3 = "A" Or P7 <> 0 Or P9 <> 0 Then
Sheets(3).Select
Cells(j, 1).Select
ActiveCell.Value = P1
Cells(j, 2).Select
ActiveCell.Value = P2
Cells(j, 3).Select
ActiveCell.Value = P3
Cells(j, 4).Select
ActiveCell.Value = P4
Cells(j, 5).Select
ActiveCell.Value = P5
Cells(j, 6).Select
ActiveCell.Value = P6
Cells(j, 7).Select
ActiveCell.Value = P7
Cells(j, 8).Select
ActiveCell.Value = P9
Cells(j, 9).Select
ActiveCell.Value = P11
j = j + 1
End If
If P7 <> 0 Or P9 <> 0 Then
Sheets(4).Select
Cells(k, 1).Select
ActiveCell.Value = P1
Cells(k, 2).Select
ActiveCell.Value = P5
Cells(k, 3).Select
ActiveCell.Value = P7
Cells(k, 4).Select
ActiveCell.Value = P8
Cells(k, 5).Select
ActiveCell.Value = P9
Cells(k, 6).Select
ActiveCell.Value = P10
Cells(k, 7).Select
ActiveCell.Value = P11
k = k + 1
End If
Next i
Sheets(2).Select
For i = l + 1 To 500
Cells(i, 1).Select
ActiveCell.Value = Null
Cells(i, 2).Select
ActiveCell.Value = Null
Cells(i, 3).Select
ActiveCell.Value = Null
Cells(i, 4).Select
ActiveCell.Value = Null
Cells(i, 5).Select
ActiveCell.Value = Null
Next i
ActiveSheet.Protect DrawingObjects:=True, contents:=True, Scenarios:=True, password:="protection1"
Sheets(3).Select
For i = j To 500
Cells(i, 1).Select
ActiveCell.Value = Null
Cells(i, 2).Select
ActiveCell.Value = Null
Cells(i, 3).Select
ActiveCell.Value = Null
Cells(i, 4).Select
ActiveCell.Value = Null
Cells(i, 5).Select
ActiveCell.Value = Null
Cells(i, 6).Select
ActiveCell.Value = Null
Cells(i, 7).Select
ActiveCell.Value = Null
Cells(i, 8).Select
ActiveCell.Value = Null
Cells(i, 9).Select
ActiveCell.Value = Null
Next i
ActiveSheet.Protect DrawingObjects:=True, contents:=True, Scenarios:=True, password:="protection2"
Sheets(4).Select
For i = k To 500
Cells(i, 1).Select
ActiveCell.Value = Null
Cells(i, 2).Select
ActiveCell.Value = Null
Cells(i, 3).Select
ActiveCell.Value = Null
Cells(i, 4).Select
ActiveCell.Value = Null
Cells(i, 5).Select
ActiveCell.Value = Null
Cells(i, 6).Select
ActiveCell.Value = Null
Cells(i, 7).Select
ActiveCell.Value = Null
Next i
ActiveSheet.Protect DrawingObjects:=True, contents:=True, Scenarios:=True, password:="protection3"
'
End Sub
Sauriez vous comment je pourrais y intégrer un élément me conservant la mise en page ?
D'avance merci.
A voir également:
- Mise en page dans une macro avec filtres
- Supprimer une page dans word - Guide
- Telecharger macro convertir chiffre en lettre excel - Télécharger - Tableur
- Mise en forme conditionnelle excel - Guide
- Mise a jour chrome - Accueil - Applications & Logiciels
- Mise a jour windows 10 - Accueil - Mise à jour
1 réponse
T'as déjà fais un post...
https://forums.commentcamarche.net/forum/affich-18944488-mise-en-page-dans-une-macro-avec-filtres
Evite les doublons.
Quand l'on poste un message sur CCM, et qu'on ne le vois pas dans la liste, il faut attendre une minute.
Si après une minute il y est, tout va bien. Si non, faut recommencer. Mais attend la minute.
https://forums.commentcamarche.net/forum/affich-18944488-mise-en-page-dans-une-macro-avec-filtres
Evite les doublons.
Quand l'on poste un message sur CCM, et qu'on ne le vois pas dans la liste, il faut attendre une minute.
Si après une minute il y est, tout va bien. Si non, faut recommencer. Mais attend la minute.