Macro erreur
Résolu
scelera
Messages postés
40
Statut
Membre
-
scelera Messages postés 40 Statut Membre -
scelera Messages postés 40 Statut Membre -
Bonjour,
Je vous transmet ci joint ma macro, lorsque je l'execute elle me met "End With" attendu et quand je remplace "End Sub" par "End With" ça me met "End Sub" attendu. Je n'y comprend rien, surement parceque je débute dan sla macro !
Merci de votre aide.
Sub Macro4()
'
' Macro4 Macro
'
' Touche de raccourci du clavier: Ctrl+r
'
Sheets("Feuil2").Select
Cells.Select
Selection.Delete Shift:=xlUp
Sheets("Feuil1").Select
Columns("G:G").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Feuil2").Select
Columns("A:A").Select
ActiveSheet.Paste
Columns("A:A").EntireColumn.AutoFit
Sheets("Feuil1").Select
Columns("H:H").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Feuil2").Select
Columns("B:B").Select
ActiveSheet.Paste
Columns("B:B").EntireColumn.AutoFit
Sheets("Feuil1").Select
Columns("I:I").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Feuil2").Select
Columns("C:C").Select
ActiveSheet.Paste
Sheets("Feuil1").Select
Columns("J:J").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Feuil2").Select
Columns("D:D").Select
ActiveSheet.Paste
Columns("D:D").EntireColumn.AutoFit
Sheets("Feuil1").Select
Columns("O:O").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Feuil2").Select
Columns("E:E").Select
ActiveSheet.Paste
Sheets("Feuil1").Select
ActiveWindow.SmallScroll ToRight:=18
Columns("AK:AK").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Feuil2").Select
Columns("F:F").Select
ActiveSheet.Paste
Columns("F:F").EntireColumn.AutoFit
Sheets("Feuil1").Select
Columns("AL:AL").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Feuil2").Select
Columns("G:G").Select
ActiveSheet.Paste
Columns("G:G").EntireColumn.AutoFit
Sheets("Feuil1").Select
ActiveWindow.LargeScroll ToRight:=-1
Columns("AH:AH").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Feuil2").Select
Columns("H:H").Select
ActiveSheet.Paste
Sheets("Feuil1").Select
ActiveWindow.LargeScroll ToRight:=1
Columns("AG:AG").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Feuil2").Select
Columns("I:I").Select
ActiveSheet.Paste
Sheets("Feuil1").Select
Columns("K:K").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Feuil2").Select
Columns("J:J").Select
ActiveSheet.Paste
Sheets("Feuil2").Select
Range("A1:J1").Select
Range("J1").Activate
Application.CutCopyMode = False
Selection.AutoFilter
ActiveWindow.View = xlPageLayoutView
With ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = "&""Arial,Gras""&20&UExtrait de nos références"
.RightHeader = ""
.LeftFooter = ""
.CenterFooter = ""
.RightFooter = ""
.LeftMargin = Application.InchesToPoints(0.25)
.RightMargin = Application.InchesToPoints(0.25)
.TopMargin = Application.InchesToPoints(0.75)
.BottomMargin = Application.InchesToPoints(0.75)
.HeaderMargin = Application.InchesToPoints(0.3)
.FooterMargin = Application.InchesToPoints(0.3)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.PrintQuality = 600
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlLandscape
.Draft = False
.PaperSize = xlPaperA4
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = 57
.PrintErrors = xlPrintErrorsDisplayed
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = False
.ScaleWithDocHeaderFooter = True
.AlignMarginsHeaderFooter = True
.EvenPage.LeftHeader.Text = ""
.EvenPage.CenterHeader.Text = ""
.EvenPage.RightHeader.Text = ""
.EvenPage.LeftFooter.Text = ""
.EvenPage.CenterFooter.Text = ""
.EvenPage.RightFooter.Text = ""
.FirstPage.LeftHeader.Text = ""
.FirstPage.CenterHeader.Text = ""
.FirstPage.RightHeader.Text = ""
.FirstPage.LeftFooter.Text = ""
.FirstPage.CenterFooter.Text = ""
.FirstPage.RightFooter.Text = ""
ActiveSheet.PageSetup.RightHeaderPicture.Filename = _
"P:\Extrait de nos références Macro\Logo TLS.png"
Application.PrintCommunication = False
With ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = "&""Arial,Gras""&20&UExtrait de nos références"
.RightHeader = "&G"
.LeftFooter = ""
.CenterFooter = ""
.RightFooter = ""
.LeftMargin = Application.InchesToPoints(0.25)
.RightMargin = Application.InchesToPoints(0.25)
.TopMargin = Application.InchesToPoints(0.75)
.BottomMargin = Application.InchesToPoints(0.75)
.HeaderMargin = Application.InchesToPoints(0.3)
.FooterMargin = Application.InchesToPoints(0.3)
.Zoom = 57
.PrintErrors = xlPrintErrorsDisplayed
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = False
.ScaleWithDocHeaderFooter = True
.AlignMarginsHeaderFooter = True
.EvenPage.LeftHeader.Text = ""
.EvenPage.CenterHeader.Text = ""
.EvenPage.RightHeader.Text = ""
.EvenPage.LeftFooter.Text = ""
.EvenPage.CenterFooter.Text = ""
.EvenPage.RightFooter.Text = ""
.FirstPage.LeftHeader.Text = ""
.FirstPage.CenterHeader.Text = ""
.FirstPage.RightHeader.Text = ""
.FirstPage.LeftFooter.Text = ""
.FirstPage.CenterFooter.Text = ""
.FirstPage.RightFooter.Text = ""
End With
Range("G3").Select
End Sub
Je vous transmet ci joint ma macro, lorsque je l'execute elle me met "End With" attendu et quand je remplace "End Sub" par "End With" ça me met "End Sub" attendu. Je n'y comprend rien, surement parceque je débute dan sla macro !
Merci de votre aide.
Sub Macro4()
'
' Macro4 Macro
'
' Touche de raccourci du clavier: Ctrl+r
'
Sheets("Feuil2").Select
Cells.Select
Selection.Delete Shift:=xlUp
Sheets("Feuil1").Select
Columns("G:G").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Feuil2").Select
Columns("A:A").Select
ActiveSheet.Paste
Columns("A:A").EntireColumn.AutoFit
Sheets("Feuil1").Select
Columns("H:H").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Feuil2").Select
Columns("B:B").Select
ActiveSheet.Paste
Columns("B:B").EntireColumn.AutoFit
Sheets("Feuil1").Select
Columns("I:I").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Feuil2").Select
Columns("C:C").Select
ActiveSheet.Paste
Sheets("Feuil1").Select
Columns("J:J").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Feuil2").Select
Columns("D:D").Select
ActiveSheet.Paste
Columns("D:D").EntireColumn.AutoFit
Sheets("Feuil1").Select
Columns("O:O").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Feuil2").Select
Columns("E:E").Select
ActiveSheet.Paste
Sheets("Feuil1").Select
ActiveWindow.SmallScroll ToRight:=18
Columns("AK:AK").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Feuil2").Select
Columns("F:F").Select
ActiveSheet.Paste
Columns("F:F").EntireColumn.AutoFit
Sheets("Feuil1").Select
Columns("AL:AL").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Feuil2").Select
Columns("G:G").Select
ActiveSheet.Paste
Columns("G:G").EntireColumn.AutoFit
Sheets("Feuil1").Select
ActiveWindow.LargeScroll ToRight:=-1
Columns("AH:AH").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Feuil2").Select
Columns("H:H").Select
ActiveSheet.Paste
Sheets("Feuil1").Select
ActiveWindow.LargeScroll ToRight:=1
Columns("AG:AG").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Feuil2").Select
Columns("I:I").Select
ActiveSheet.Paste
Sheets("Feuil1").Select
Columns("K:K").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Feuil2").Select
Columns("J:J").Select
ActiveSheet.Paste
Sheets("Feuil2").Select
Range("A1:J1").Select
Range("J1").Activate
Application.CutCopyMode = False
Selection.AutoFilter
ActiveWindow.View = xlPageLayoutView
With ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = "&""Arial,Gras""&20&UExtrait de nos références"
.RightHeader = ""
.LeftFooter = ""
.CenterFooter = ""
.RightFooter = ""
.LeftMargin = Application.InchesToPoints(0.25)
.RightMargin = Application.InchesToPoints(0.25)
.TopMargin = Application.InchesToPoints(0.75)
.BottomMargin = Application.InchesToPoints(0.75)
.HeaderMargin = Application.InchesToPoints(0.3)
.FooterMargin = Application.InchesToPoints(0.3)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.PrintQuality = 600
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlLandscape
.Draft = False
.PaperSize = xlPaperA4
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = 57
.PrintErrors = xlPrintErrorsDisplayed
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = False
.ScaleWithDocHeaderFooter = True
.AlignMarginsHeaderFooter = True
.EvenPage.LeftHeader.Text = ""
.EvenPage.CenterHeader.Text = ""
.EvenPage.RightHeader.Text = ""
.EvenPage.LeftFooter.Text = ""
.EvenPage.CenterFooter.Text = ""
.EvenPage.RightFooter.Text = ""
.FirstPage.LeftHeader.Text = ""
.FirstPage.CenterHeader.Text = ""
.FirstPage.RightHeader.Text = ""
.FirstPage.LeftFooter.Text = ""
.FirstPage.CenterFooter.Text = ""
.FirstPage.RightFooter.Text = ""
ActiveSheet.PageSetup.RightHeaderPicture.Filename = _
"P:\Extrait de nos références Macro\Logo TLS.png"
Application.PrintCommunication = False
With ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = "&""Arial,Gras""&20&UExtrait de nos références"
.RightHeader = "&G"
.LeftFooter = ""
.CenterFooter = ""
.RightFooter = ""
.LeftMargin = Application.InchesToPoints(0.25)
.RightMargin = Application.InchesToPoints(0.25)
.TopMargin = Application.InchesToPoints(0.75)
.BottomMargin = Application.InchesToPoints(0.75)
.HeaderMargin = Application.InchesToPoints(0.3)
.FooterMargin = Application.InchesToPoints(0.3)
.Zoom = 57
.PrintErrors = xlPrintErrorsDisplayed
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = False
.ScaleWithDocHeaderFooter = True
.AlignMarginsHeaderFooter = True
.EvenPage.LeftHeader.Text = ""
.EvenPage.CenterHeader.Text = ""
.EvenPage.RightHeader.Text = ""
.EvenPage.LeftFooter.Text = ""
.EvenPage.CenterFooter.Text = ""
.EvenPage.RightFooter.Text = ""
.FirstPage.LeftHeader.Text = ""
.FirstPage.CenterHeader.Text = ""
.FirstPage.RightHeader.Text = ""
.FirstPage.LeftFooter.Text = ""
.FirstPage.CenterFooter.Text = ""
.FirstPage.RightFooter.Text = ""
End With
Range("G3").Select
End Sub
A voir également:
- Macro erreur
- Telecharger macro convertir chiffre en lettre excel - Télécharger - Tableur
- Jitbit macro recorder - Télécharger - Confidentialité
- Erreur 0x80070643 - Accueil - Windows
- Iptv erreur de lecture - Forum TV & Vidéo
- Erreur 4201 france tv ✓ - Forum Réseaux sociaux
2 réponses
Suite... un petit conseil quand tu développes, indentes bien ton code (décalage), comme ça tu vois rapidement où tu n'as pas fermé.
Sub Macro .... With ActiveSheet.PageSetup .LeftHeader = "" .CenterHeader = "&""Arial,Gras""&20&UExtrait de nos références" .RightHeader = "" End with End Sub
Hello , pour Tout With il faut un End With.
Donc il manque un End With pour fermer le With ActiveSheet.PageSetup après le .FirstPage.RightFooter.Text = ""
Par contre ta macro est assez bizarre, par exemple pourquoi avoir 2 fois le "With ActiveSheet.PageSetup"
Sinon bonne continuation
Cordialement
Donc il manque un End With pour fermer le With ActiveSheet.PageSetup après le .FirstPage.RightFooter.Text = ""
Par contre ta macro est assez bizarre, par exemple pourquoi avoir 2 fois le "With ActiveSheet.PageSetup"
Sinon bonne continuation
Cordialement
Je pense que le problème viens du fait que tu ais 2 fois le "With ActiveSheet.PageSetup"
J'ai l'impression que le 2ème ne sert à rien et qu'il réinitialise l'entête.
Enlèves le. De toute façon pour affiche une image dans la partie droite de l'entete il ne faut que 2 lignes:
La 1ère ligne indique où chercher l'image et la seconde dans quelle zone l'insérer.
Tes soucis viennent surement de l'enregistreur de macro. C'est mieux quand même de relire le code, de bien le présenter, de retirer tout ce qui ne sert à rien
cordialement
J'ai l'impression que le 2ème ne sert à rien et qu'il réinitialise l'entête.
Enlèves le. De toute façon pour affiche une image dans la partie droite de l'entete il ne faut que 2 lignes:
ActiveSheet.PageSetup.RightHeaderPicture.filename = "P:\Extrait de nos références Macro\Logo TLS.png" ActiveSheet.PageSetup.RightHeader = "&G"
La 1ère ligne indique où chercher l'image et la seconde dans quelle zone l'insérer.
Tes soucis viennent surement de l'enregistreur de macro. C'est mieux quand même de relire le code, de bien le présenter, de retirer tout ce qui ne sert à rien
cordialement