Hieronder twee identieke macro's voor het printen.
Het enige verschil is dat de Range/Kolommen verschillend is.
Ik vraag me af of dit niet in één macro kan worden verwerkt, kwestie van eenvoud.
Met oprechte dank voor elke aanzet tot verkorting.
Sub druk1() ' Volledig
Application.EnableEvents = False
Application.ScreenUpdating = False
Dim lastCell As Long
lastCell = Range("A" & Rows.Count).End(xlUp).Row
Columns("O:R").EntireColumn.Hidden = True
ActiveSheet.PageSetup.RightFooter = "Gedrukt &D"
ActiveSheet.PageSetup.CenterFooter = "Pagina &P - &N"
ActiveSheet.PageSetup.LeftFooter = "Blad1"
ActiveSheet.PageSetup.PrintArea = "A1:N" & lastCell
ActiveSheet.Range("A4:R1000").Interior.ColorIndex = 0
If Application.Dialogs(xlDialogPrinterSetup).Show Then
ActiveSheet.PrintOut
Columns("O:R").EntireColumn.Hidden = False
End If
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub
______________________________________
Sub druk() ' Beperkt
Application.EnableEvents = False
Application.ScreenUpdating = False
Dim lastCell As Long
lastCell = Range("A" & Rows.Count).End(xlUp).Row
Range("E:E,G:G,I:I,K:L,N:N").EntireColumn.Hidden = True
ActiveSheet.PageSetup.RightFooter = "Gedrukt &D"
ActiveSheet.PageSetup.CenterFooter = "Pagina &P - &N"
ActiveSheet.PageSetup.LeftFooter = "Blad1"
ActiveSheet.PageSetup.PrintArea = "A1:R" & lastCell
ActiveSheet.Range("A4:R1000").Interior.ColorIndex = 0
If Application.Dialogs(xlDialogPrinterSetup).Show Then
ActiveSheet.PrintOut
Range("E:E,G:G,I:I,K:L,N:N").EntireColumn.Hidden = False
End If
Application.EnableEvents = True
Application.ScreenUpdating = True
End If
End Sub
Het enige verschil is dat de Range/Kolommen verschillend is.
Ik vraag me af of dit niet in één macro kan worden verwerkt, kwestie van eenvoud.
Met oprechte dank voor elke aanzet tot verkorting.
Sub druk1() ' Volledig
Application.EnableEvents = False
Application.ScreenUpdating = False
Dim lastCell As Long
lastCell = Range("A" & Rows.Count).End(xlUp).Row
Columns("O:R").EntireColumn.Hidden = True
ActiveSheet.PageSetup.RightFooter = "Gedrukt &D"
ActiveSheet.PageSetup.CenterFooter = "Pagina &P - &N"
ActiveSheet.PageSetup.LeftFooter = "Blad1"
ActiveSheet.PageSetup.PrintArea = "A1:N" & lastCell
ActiveSheet.Range("A4:R1000").Interior.ColorIndex = 0
If Application.Dialogs(xlDialogPrinterSetup).Show Then
ActiveSheet.PrintOut
Columns("O:R").EntireColumn.Hidden = False
End If
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub
______________________________________
Sub druk() ' Beperkt
Application.EnableEvents = False
Application.ScreenUpdating = False
Dim lastCell As Long
lastCell = Range("A" & Rows.Count).End(xlUp).Row
Range("E:E,G:G,I:I,K:L,N:N").EntireColumn.Hidden = True
ActiveSheet.PageSetup.RightFooter = "Gedrukt &D"
ActiveSheet.PageSetup.CenterFooter = "Pagina &P - &N"
ActiveSheet.PageSetup.LeftFooter = "Blad1"
ActiveSheet.PageSetup.PrintArea = "A1:R" & lastCell
ActiveSheet.Range("A4:R1000").Interior.ColorIndex = 0
If Application.Dialogs(xlDialogPrinterSetup).Show Then
ActiveSheet.PrintOut
Range("E:E,G:G,I:I,K:L,N:N").EntireColumn.Hidden = False
End If
Application.EnableEvents = True
Application.ScreenUpdating = True
End If
End Sub