max_max
Board Regular
- Joined
- Jun 29, 2013
- Messages
- 58
Hi to all
is it possible to add to the macro not to print pages 5/6 or 3/4 if they are blank?
Now the page order is in horizontal priority.
is it possible to add to the macro not to print pages 5/6 or 3/4 if they are blank?
Now the page order is in horizontal priority.
VBA Code:
'Public NoPrint As Boolean
Option Explicit
Sub stampa_tagli()
Dim avviso As String
ActiveSheet.Unprotect ' "987654"
Application.ScreenUpdating = False
avviso = MsgBox("Stampo tabella?" & Chr(13) & Chr(13) & _
"Prima di stampare controlla " & Chr(13) & _
"le interruzioni di pagina!", vbQuestion + vbYesNo + vbDefaultButton2, "STAMPA")
If avviso = vbNo Then
ActiveSheet.Protect ' "987654"
Exit Sub
End If
'------------------------------------------------------------------------------------
ActiveWindow.View = xlPageBreakPreview
ActiveSheet.PageSetup.PrintArea = "$C$2:$BB$121"
Set ActiveSheet.VPageBreaks(1).Location = Range("AO2")
Set ActiveSheet.VPageBreaks(1).Location = Range("AD2")
'ActiveSheet.PageSetup.PrintArea = "$C$2:$BB$121"
Set ActiveSheet.HPageBreaks(1).Location = Range("C42")
Set ActiveSheet.HPageBreaks(2).Location = Range("C82")
ActiveSheet.PageSetup.PrintArea = "$C$2:$BB$121"
ActiveWindow.View = xlNormalView
'------------------------------------------------------------------------------------
'If WorksheetFunction.CountA(Range("AD3:BA121")) = 0 Then '<<<<< not work
If Application.CountIfs(Range("AD3:BA121"), "<>0") = 0 Then
Columns("AD:BA").Select
Selection.EntireColumn.Hidden = True
ActiveSheet.PageSetup.PrintArea = "$C$2:$BB$121"
With ActiveSheet.PageSetup
.Zoom = 78
End With
ActiveWindow.View = xlPageBreakPreview
ActiveSheet.VPageBreaks(1).DragOff Direction:=xlToRight, RegionIndex:=1
'NoPrint = True
ActiveWindow.SelectedSheets.PrintPreview
'NoPrint = False
Columns("AC:BB").Select
Selection.EntireColumn.Hidden = False
ActiveSheet.PageSetup.PrintArea = "$C$2:$BG$121"
Set ActiveSheet.VPageBreaks(1).Location = Range("AD2")
'ActiveSheet.PageSetup.PrintArea = "$C$2:$BB$121"
Set ActiveSheet.HPageBreaks(1).Location = Range("C42")
Set ActiveSheet.HPageBreaks(2).Location = Range("C82")
ActiveSheet.PageSetup.PrintArea = "$C$2:$BB$121"
'ActiveWindow.View = xlPageBreakPreview
ActiveWindow.View = xlNormalView
Range("D3").Select
Else
If WorksheetFunction.CountA(Range("AD3:BA121")) >= 0 Then
ActiveSheet.PageSetup.PrintArea = "$C$2:$BB$121"
With ActiveSheet.PageSetup
.Zoom = 78
End With
'NoPrint = True
ActiveWindow.SelectedSheets.PrintPreview
'NoPrint = False
ActiveWindow.View = xlPageBreakPreview
ActiveSheet.PageSetup.PrintArea = "$C$2:$BG$121"
Set ActiveSheet.VPageBreaks(1).Location = Range("AD2")
'ActiveSheet.PageSetup.PrintArea = "$C$2:$BB$121"
Set ActiveSheet.HPageBreaks(1).Location = Range("C42")
Set ActiveSheet.HPageBreaks(2).Location = Range("C82")
ActiveSheet.PageSetup.PrintArea = "$C$2:$BB$121"
ActiveWindow.View = xlNormalView
Range("D3").Select
End If
End If
'------------------------------------------------------------------------------------
'ActiveSheet.Protect '"987654"
Application.ScreenUpdating = True
End Sub