
Sub Stampa_Scheda()
' Rimuovo i filtri se presenti nel foglio
If ActiveSheet.FilterMode = True Then ActiveSheet.ShowAllData
ActiveSheet.Unprotect "croci" 'RIMUOVERE PROTEZIONE SE SI VUOLE AGIRE SUELLE CELLE
' Cerco l'ultima riga da stampare
Riga = Columns("A:D").Find("*", , xlFormulas, , xlRows, xlPrevious).Row
' Scopro tutte le righe nascoste
Cells.EntireRow.Hidden = False
' Cerco i valori Zero nella quarta colonna
' Nascondo le righe trovate
For ciclo = 3 To Riga
If Not IsEmpty(Cells(ciclo, 4).Value) Then
If Cells(ciclo, 4).Value = 0 Then
Rows(ciclo).EntireRow.Hidden = True
End If
End If
Next
' Imposto l'area di stampa
ActiveSheet.PageSetup.PrintArea = "$A$1:$D$" & Riga
' Stampo il foglio
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, IgnorePrintAreas:=False
ActiveSheet.Protect "croci" 'RIMETTERE PROTEZIONE
End Sub |
Sub Stampa_Scheda()
Dim blnProt As Boolean
If ActiveSheet.ProtectContents = True Then blnProt = 1
' Rimuovo i filtri se presenti nel foglio
If ActiveSheet.FilterMode = True Then ActiveSheet.ShowAllData
ActiveSheet.Unprotect "croci"
' Cerco l'ultima riga da stampare
Riga = Columns("A:D").Find("*", , xlFormulas, , xlRows, xlPrevious).Row
' Scopro tutte le righe nascoste
Cells.EntireRow.Hidden = False
' Cerco i valori Zero nella quarta colonna
' Nascondo le righe trovate
For ciclo = 3 To Riga
If Not IsEmpty(Cells(ciclo, 4).Value) Then
If Cells(ciclo, 4).Value = 0 Then
Rows(ciclo).EntireRow.Hidden = True
End If
End If
Next
' Imposto l'area di stampa
ActiveSheet.PageSetup.PrintArea = "$A$1:$D$" & Riga
' Stampo il foglio
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, IgnorePrintAreas:=False
If blnProt Then ActiveSheet.Protect "croci"
End Sub |
