XL 2013 Garder la mise en forme malgré une macro

degards

XLDnaute Occasionnel
Bonjour à vous !!! J'ai besoin de votre soutient afin de trouver une solution à mon problème. J'ai créé un feuille afin de faire un topo de notre journée de travail. On m'a demandé d'ajouter deux cases et c'est là que ça bloque. J'aimerais conserver la mise en forme présente et que lorsque j'appuie sur "ENVOYER TOPO", il faut que l'impression PDF comprenne tout y ce que l'on voit à l'écran de la ligne 1 à la ligne correspondante à la ligne sous "AUTRES" présentement en B11. Je veux que la hauteur des lignes titre demeure la même lorsque "j'AJOUTE UN ÉVÉNEMENT".

Merci à l'avance !!!
 

Pièces jointes

  • Topo 2.0.xlsm
    42.4 KB · Affichages: 19
Solution
Re,

petite modification, comme cela tu peux ajouter toutes les lignes que tu veux avant ou après ton tableau.

Bien cordialement, @+
Code:
Sub ajoutenregistrement()
'
' ajoutenregistrement Macro
'

'
    With ActiveSheet
        .Unprotect
        .Rows(.Range("Tableau7")(.Range("Tableau7").Count).Row + 1).Insert Shift:=xlDown
        .ListObjects("Tableau7").Resize Range("$A$" & [Tableau7[#headers]].Row & ":$B$" & .Range("Tableau7")(.Range("Tableau7").Count).Row + 1)
        .Protect DrawingObjects:=True, Contents:=True, Scenarios:=True, AllowFormattingCells:=True, AllowFormattingRows:=True, _
            AllowInsertingRows:=True, AllowFiltering:=True, AllowUsingPivotTables:=True
    End With
End Sub

Bernard_XLD

XLDnaute Barbatruc
Membre du Staff
Bonjour degards, le forum

Voila ton fichier modifié !
[édition : c'est fait aussi pour le pdf, j'ai juste changé la formule d'area]
Bien cordialement, @+
VB:
Sub ajoutenregistrement()
'
' ajoutenregistrement Macro
'

'
    With ActiveSheet
        .Unprotect
        .Rows(.Range("Tableau7")(.Range("Tableau7").Count).Row + 1).Insert Shift:=xlDown
        .ListObjects("Tableau7").Resize Range("$A$4:$B$" & .Range("Tableau7")(.Range("Tableau7").Count).Row + 1)
        .Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
            , AllowFormattingCells:=True, AllowFormattingRows:=True, _
            AllowInsertingRows:=True, AllowFiltering:=True, AllowUsingPivotTables:=True
    End With
End Sub
 

Pièces jointes

  • Topo 2.0-1.xlsm
    34.6 KB · Affichages: 3

Bernard_XLD

XLDnaute Barbatruc
Membre du Staff
Re,

petite modification, comme cela tu peux ajouter toutes les lignes que tu veux avant ou après ton tableau.

Bien cordialement, @+
Code:
Sub ajoutenregistrement()
'
' ajoutenregistrement Macro
'

'
    With ActiveSheet
        .Unprotect
        .Rows(.Range("Tableau7")(.Range("Tableau7").Count).Row + 1).Insert Shift:=xlDown
        .ListObjects("Tableau7").Resize Range("$A$" & [Tableau7[#headers]].Row & ":$B$" & .Range("Tableau7")(.Range("Tableau7").Count).Row + 1)
        .Protect DrawingObjects:=True, Contents:=True, Scenarios:=True, AllowFormattingCells:=True, AllowFormattingRows:=True, _
            AllowInsertingRows:=True, AllowFiltering:=True, AllowUsingPivotTables:=True
    End With
End Sub
 

degards

XLDnaute Occasionnel
Merci de ta réponse cela fonctionne très bien , c'est vraiment sympa
Bonjour degards, le forum

Voila ton fichier modifié !
[édition : c'est fait aussi pour le pdf, j'ai juste changé la formule d'area]
Bien cordialement, @+
VB:
Sub ajoutenregistrement()
'
' ajoutenregistrement Macro
'

'
    With ActiveSheet
        .Unprotect
        .Rows(.Range("Tableau7")(.Range("Tableau7").Count).Row + 1).Insert Shift:=xlDown
        .ListObjects("Tableau7").Resize Range("$A$4:$B$" & .Range("Tableau7")(.Range("Tableau7").Count).Row + 1)
        .Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
            , AllowFormattingCells:=True, AllowFormattingRows:=True, _
            AllowInsertingRows:=True, AllowFiltering:=True, AllowUsingPivotTables:=True
    End With
End Sub
 

Discussions similaires

Réponses
12
Affichages
226

Statistiques des forums

Discussions
312 321
Messages
2 087 265
Membres
103 501
dernier inscrit
talebafia