Bonsoir à tous,
Avec la macro cidessous tout fonctionne, mais vu que j'ai des fichiers avec beaucoup de lignes ( moyenne 3000) c'est extrement long . Deux heures pour 2086 lignes, ci joint le fichier.
Pourriez vous me dire ci cela vient du code ci dessous ;
Sub numeroPageCelluleActive()
Range("k2").Select
Application.ScreenUpdating = False
ActiveWindow.View = xlPageBreakPreview
dl = Range("J" & Rows.Count).End(xlUp).Row
For i = 2 To dl
ActiveCell = numeroPage(ActiveCell)
ActiveCell.Offset(1, 0).Select
Next
ActiveWindow.View = xlNormalView
Application.ScreenUpdating = True
End Sub
Function numeroPage(Cellule As Range) As Integer
Dim VPC As Integer, HPC As Integer
Dim VPB As VPageBreak, HPB As HPageBreak
Dim Wksht As Worksheet
Dim Col As Integer, Ligne As Long
Set Wksht = Cellule.Worksheet
Ligne = Cellule.Row
Col = Cellule.Column
If Wksht.PageSetup.Order = xlDownThenOver Then
HPC = Wksht.HPageBreaks.Count + 1
VPC = 1
Else
VPC = Wksht.VPageBreaks.Count + 1
HPC = 1
End If
numeroPage = 1
For Each VPB In Wksht.VPageBreaks
If VPB.Location.Column > Col Then Exit For
numeroPage = numeroPage + HPC
Next VPB
For Each HPB In Wksht.HPageBreaks
If HPB.Location.Row > Ligne Then Exit For
numeroPage = numeroPage + VPC
Next HPB
End Function
Merci de votre aide