Pagina precedente | 1 | Pagina successiva
Vota | Stampa | Notifica email    
Autore

stampa righe attive - non vuote

Ultimo Aggiornamento: 14/07/2022 17:05
Post: 461
Registrato il: 28/05/2011
Città: MILANO
Età: 43
Utente Senior
excel 2000/2007
OFFLINE
07/07/2022 22:49

Ciao,
la macro allegata dovrebbe stampare solo le righe non vuote.
E' impostata anche ripeti titoli - righe in alto.
Non funziona correttamente, stampa anche le righe vuote.
Un aiuto?
Grazie


Option Explicit

Sub stampa_tutte_righe_attive_archivio_input() 'filtro
'stampa righe attive foglio archivio_input

Dim Avviso As String

Application.ScreenUpdating = False
ActiveSheet.Unprotect "987654"  'password


 Avviso = MsgBox("stampo le righe attive?", vbInformation + vbYesNo + vbDefaultButton2, "AVVISO!")
 If Avviso = vbNo Then
 Exit Sub
 
 End If
 
 
 If Range("A5") = "" Then
Avviso = MsgBox("non c'è niente da stampare!", vbInformation + vbOKOnly + vbDefaultButton2, "AVVISO")
 If Avviso = vbOK Then
Exit Sub
 End If
 End If
  
 
 Application.Calculation = xlCalculationManual '<=== riga aggiunta
    ActiveSheet.Range("$A$4:$R$2005").AutoFilter Field:=1, Criteria1:="<>"
    
        'ActiveWindow.SelectedSheets.PrintPreview
        ActiveSheet.PrintPreview
    ActiveSheet.Range("$A$4:$R$2005").AutoFilter Field:=1
    
 'ActiveSheet.Protect "987654"  'password
 ActiveSheet.Protect Password:="987654", DrawingObjects:=True, Contents:=True, Scenarios:=True _
        , AllowFormattingCells:=False, AllowInsertingHyperlinks:=False, AllowFiltering:=True

Application.ScreenUpdating = True
 Application.Calculation = xlAutomatic '<=== riga aggiunta
 
 [A5].Select
 
End Sub


[Modificato da john_cash 07/07/2022 22:51]
---------------
excel 2007
Post: 1.230
Registrato il: 16/08/2015
Città: CORDENONS
Età: 67
Utente Veteran
Excel 2016-32bit Win11
OFFLINE
07/07/2022 23:34

A me stampa regolarmente tutte le righe utilizzate, in pratica fino alla riga 23 (ZZZ). Ma il problema è che hai impostato delle Interruzioni di Pagina che stravolgono la stampa e che l'Anteprima non ti da un chiaro quadro del risultato finale.

______________________________________________________________
C'è chi fa le COSE a CASO e chi fa CASO alle COSE (Ignoto)
Post: 461
Registrato il: 28/05/2011
Città: MILANO
Età: 43
Utente Senior
excel 2000/2007
OFFLINE
09/07/2022 14:33

Ciao,
non riesco a capire come correggere, continua a stampare fogli vuoti alla fine
---------------
excel 2007
Post: 1.232
Registrato il: 16/08/2015
Città: CORDENONS
Età: 67
Utente Veteran
Excel 2016-32bit Win11
OFFLINE
09/07/2022 16:31

Ti ho detto che a me funziona. Boh, inizia col ripulire il Layout di Pagina e vediamo se nel tuo PC la situazione migliora:
Nel menu Layout di Pagina / Area di Stampa / clicca Cancella Area di Stampa poi in Interruzioni / clicca Reimposta tutte le Interruzioni di Pagina e poi rilancia la tua macro e vedi cosa succede.

______________________________________________________________
C'è chi fa le COSE a CASO e chi fa CASO alle COSE (Ignoto)
Post: 1.518
Registrato il: 27/06/2011
Utente Veteran
excel 2007
OFFLINE
14/07/2022 13:16

prova

vb
Option Explicit

Sub stampa_tutte_righe_attive_archivio_input() 'filtro
'stampa righe attive foglio archivio_input

Dim Avviso As String



Application.ScreenUpdating = False
ActiveSheet.Unprotect "987654"  'password


 Avviso = MsgBox("stampo le righe attive?", vbInformation + vbYesNo + vbDefaultButton2, "AVVISO!")
 If Avviso = vbNo Then
 Exit Sub
 
 End If
 
 
 If Range("A5") = "" Then
Avviso = MsgBox("non c'è niente da stampare!", vbInformation + vbOKOnly + vbDefaultButton2, "AVVISO")
 If Avviso = vbOK Then
Exit Sub
 End If
 End If
  
 
 Application.Calculation = xlCalculationManual '<=== riga aggiunta
    ActiveSheet.Range("$A$4:$R$2005").AutoFilter Field:=1, Criteria1:="<>"
    
        'ActiveWindow.SelectedSheets.PrintPreview
        ActiveSheet.PrintPreview
    
    
 'ActiveSheet.Protect "987654"  'password
 ActiveSheet.Protect Password:="987654", DrawingObjects:=True, Contents:=True, Scenarios:=True _
        , AllowFormattingCells:=False, AllowInsertingHyperlinks:=False, AllowFiltering:=True

Application.ScreenUpdating = True
 Application.Calculation = xlAutomatic '<=== riga aggiunta
 
 [A5].Select
 
End Sub








Stretta la foglia, larga la via, dite la vostra che ho detto la mia.
Excel 2007 forse anche 2013 ... 2021 ... 365 e future...
Post: 1.520
Registrato il: 27/06/2011
Utente Veteran
excel 2007
OFFLINE
14/07/2022 17:05



vb
Option Explicit

Sub stampa_tutte_righe_attive_archivio_input() 'filtro

Dim Avviso As String

Dim area As Range, ur As Long
ur = Cells(Rows.Count, "a").End(xlUp).Row


Application.ScreenUpdating = False
ActiveSheet.Unprotect "987654"  'password


 Avviso = MsgBox("stampo le righe attive?", vbInformation + vbYesNo + vbDefaultButton2, "AVVISO!")
 If Avviso = vbNo Then
 Exit Sub
 
 End If
 
 
 If Range("A5") = "" Then
Avviso = MsgBox("non c'è niente da stampare!", vbInformation + vbOKOnly + vbDefaultButton2, "AVVISO")
 If Avviso = vbOK Then
Exit Sub
 End If
 End If
  
 
 Application.Calculation = xlCalculationManual '<=== riga aggiunta
    ActiveSheet.Range("$A$4:$R$2005").AutoFilter Field:=1, Criteria1:="<>"
    
Set area = Range("a4:r" & ur)
        
area.PrintOut

ActiveSheet.Range("$A$4:$R$2005").AutoFilter Field:=1

 
 ActiveSheet.Protect Password:="987654", DrawingObjects:=True, Contents:=True, Scenarios:=True _
        , AllowFormattingCells:=False, AllowInsertingHyperlinks:=False, AllowFiltering:=True

Application.ScreenUpdating = True
Application.Calculation = xlAutomatic '<=== riga aggiunta
 
 
 [A5].Select
 
 Set area = Nothing
End Sub








Stretta la foglia, larga la via, dite la vostra che ho detto la mia.
Excel 2007 forse anche 2013 ... 2021 ... 365 e future...
Vota:
Amministra Discussione: | Chiudi | Sposta | Cancella | Modifica | Notifica email Pagina precedente | 1 | Pagina successiva
Nuova Discussione
 | 
Rispondi
Feed | Forum | Bacheca | Album | Utenti | Cerca | Login | Registrati | Amministra
Tutti gli orari sono GMT+01:00. Adesso sono le 05:05. Versione: Stampabile | Mobile | Regolamento | Privacy
FreeForumZone [v.6.1] - Copyright © 2000-2024 FFZ srl - www.freeforumzone.com