Définir zone imprssion vba

Fermé
benama34 - 27 oct. 2007 à 15:57
Papou93 Messages postés 146 Date d'inscription mercredi 4 avril 2007 Statut Membre Dernière intervention 5 juin 2012 - 27 oct. 2007 à 20:32
Bonjour,
Bonjour,

petit pb d'impression

grace a cette fonction je défint ma plage de cellule à imprimer
j = 1
Do
Cells(j, 1).Select
j = j + 1
Loop While Cells(j, 1) <> ""
j = j - 1
Range(Cells(1, 1), Cells(j, 3)).Select

'puis je défint la mise en page

ActiveSheet.PageSetup.PrintArea = Range(Cells(1, 1), Cells(j, 3))

biensur ca ne marche pas au niveau de print area. quelqu'un peut il m'aider
thanks

1 réponse

Papou93 Messages postés 146 Date d'inscription mercredi 4 avril 2007 Statut Membre Dernière intervention 5 juin 2012 59
27 oct. 2007 à 20:32
Bonjour benama34,

Corriges ton code comme suit :

j = 1 
Do 
Cells(j, 1).Select 
j = j + 1 
Loop While Cells(j, 1) <> "" 
j = j - 1 
Range(Cells(1, 1), Cells(j, 3)).Select 
ActiveSheet.PageSetup.PrintArea = Selection.Address


ou plus simplement :

j = 1 
Do 
Cells(j, 1).Select 
j = j + 1 
Loop While Cells(j, 1) <> "" 
j = j - 1 
ActiveSheet.PageSetup.PrintArea = Range(Cells(1, 1), Cells(j, 3)).Address


Ou encore plus simple :

j=Range("A65536").End(xlUp).Row
ActiveSheet.PageSetup.PrintArea = Range(Cells(1, 1), Cells(j, 3)).Address


A toi de choisir !

Cordialement.
0