Numérotation des feuilles

Bonjour,

J'ai un fichier avec de nombreuses feuilles. Sur chacune des feuilles il y a des tableaux assez grands qui font que quand j'imprime, j'ai plusieurs pages par feuille de mon tableur. J'ai sur chaque feuille un bouton auquel est affectée une macro qui m'affiche un aperçu de la feuille active. Cette macro est donc la même pour toutes les feuilles.

Je voudrais commencer la numérotation à 20 et j'ai trouvé comment l'ajouter dans ma macro. Le problème c'est que comme la macro est sur chaque feuille, elles commencent toutes à 20. Or j'aimerai que la feuille 1 soit numérotée 20 et que les feuilles suivantes soient numérotées à la suite. Pour afficher l'aperçu, j'utilise la macro suivante :

Sub Impression1()

Sheets("Feuil1").Visible = True

Sheets("Feuil2").Visible = True

Sheets("Feuil3").Visible = True

Sheets("Feuil4").Visible = True

Sheets("Feuil5").Visible = True

Sheets("Feuil6").Visible = True

Sheets(Array("Feuil1", "Feuil2", "Feuil3", "Feuil4", "Feuil5", "Feuil6")).Select

Sheets("Feuil1").Activate

Application.PrintCommunication = False

With ActiveSheet.PageSetup

.LeftHeader = "&G"

.CenterHeader = ""

.RightHeader = "Document Unique"

.LeftFooter = ""

.CenterFooter = ""

.RightFooter = "&D"

.LeftMargin = Application.InchesToPoints(0.708661417322835)

.RightMargin = Application.InchesToPoints(0.708661417322835)

.TopMargin = Application.InchesToPoints(0.748031496062992)

.BottomMargin = Application.InchesToPoints(0.748031496062992)

.HeaderMargin = Application.InchesToPoints(0.31496062992126)

.FooterMargin = Application.InchesToPoints(0.31496062992126)

.PrintHeadings = False

.PrintGridlines = False

.PrintComments = xlPrintSheetEnd

.PrintQuality = 600

.CenterHorizontally = True

.CenterVertically = False

.Orientation = xlLandscape

.Draft = False

.PaperSize = xlPaperA4

.FirstPageNumber = 20

.Order = xlDownThenOver

.BlackAndWhite = False

.Zoom = False

.FitToPagesWide = 1

.FitToPagesTall = False

.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

Application.PrintCommunication = True

ActiveWindow.SelectedSheets.PrintPreview

Sheets("Feuil7").Select

Sheets("Feuil1").Visible = False

Sheets("Feuil2").Visible = False

Sheets("Feuil3").Visible = False

Sheets("Feuil4").Visible = False

Sheets("Feuil5").Visible = False

Sheets("Feuil6").Visible = False

End Sub

La ligne rouge me permet de démarrer la numérotation à la 20ème page. Ça ne me dérangerait pas de créer cette macro pour chacune des feuilles et faire varier la ligne rouge pour que les chiffres se suivent mais je vais devoir changer chaque macro si les tableaux sont agrandis.

Quelqu'un aurait une solution ?

Merci d'avance

Bonjour,

Pour moi une boucle for pourrait suffire. testez la macro suivante

sub essai()
dim i as variant
for i=20 to worksheets.count
call Impression1
next i
end sub

Et dans votre macro, remplacez la ligne rouge par

.FirstPageNumber = i

Je n'ai pas testé mais ça devrai fonctionner

Cordialement

Je me suis trompé sur la macro, en fait j'utilise celle-ci :

Sub Imprimer() 'Fait apparaître la fenêtre permettant d'imprimer la feuille active uniquement'

ActiveSheet.Select

Application.PrintCommunication = False

With ActiveSheet.PageSetup

.LeftHeader = "&G"

.CenterHeader = ""

.RightHeader = "Document Unique"

.LeftFooter = "&D"

.CenterFooter = ""

.RightFooter = "&P"

.LeftMargin = Application.InchesToPoints(0.708661417322835)

.RightMargin = Application.InchesToPoints(0.708661417322835)

.TopMargin = Application.InchesToPoints(0.748031496062992)

.BottomMargin = Application.InchesToPoints(0.748031496062992)

.HeaderMargin = Application.InchesToPoints(0.31496062992126)

.FooterMargin = Application.InchesToPoints(0.31496062992126)

.PrintHeadings = False

.PrintGridlines = False

.PrintComments = xlPrintSheetEnd

.PrintQuality = 600

.CenterHorizontally = True

.CenterVertically = False

.Orientation = xlLandscape

.Draft = False

.PaperSize = xlPaperA4

.FirstPageNumber = 20

.Order = xlDownThenOver

.BlackAndWhite = False

.Zoom = False

.FitToPagesWide = 1

.FitToPagesTall = False

.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

Application.PrintCommunication = True

ActiveWindow.SelectedSheets.PrintPreview

ActiveSheet.Select

End Sub

Je ne sais pas si c'est dû à mon erreur mais quand je clique sur mon bouton d'aperçu, la feuille s'affiche avec le numéro de page 20 et quand je clique sur "page suivante", le numéro de page est 21 : jusque là pas de soucis. Mais quand je ferme l'aperçu, il s'ouvre tout seul en m'affichant la même feuille mais cette fois-ci la numérotation commence à 22... Et ainsi de suite à chaque fois que je ferme l'aperçu

Rechercher des sujets similaires à "numerotation feuilles"