ciao,
sapete se è possibile stampare una tabella "lunga e stretta" su due colonne, in una pagina, come in word?
Moderatori: Anthony47, Flash30005
wallace&gromit ha scritto: ho trascurato di dire... ... è una tabella pivot!
Sub WnG2()
'
On Error Resume Next
Application.DisplayAlerts = False
Sheets("ZcWork").Delete
Sheets("ZcPrint").Delete
On Error GoTo 0
Application.DisplayAlerts = True
'
TabSh = "Foglio4" '<<<-- Il foglio con la tabella di origine
'NB: il prossimo parametro deve cominciare da A1;
'es: corretto A1:F1
' sbagliati B1:F1, A2:G2
Tab1Adr = "A1:D1" '<<<-- La larghezza della prima tabella
'
Tab2Adr = Range(Tab1Adr).Offset(0, Range(Tab1Adr).Count + 1).Address
LastCol = Range(Tab2Adr).Offset(0, Range(Tab1Adr).Count - 1).Column
'
'Crea copia del foglio con Pivot
Sheets(TabSh).Copy After:=Sheets(Sheets.Count)
ActiveSheet.Name = "ZcWork"
Range(Tab1Adr).Resize(20, Range(Tab1Adr).Count).Copy Destination:=Range(Tab2Adr)
'Imposta larghezza colonne come originale
For Each TabC In Range(Tab1Adr)
Range(Tab2Adr).Offset(0, I).ColumnWidth = TabC.ColumnWidth
I = I + 1
Next TabC
With ActiveSheet.PageSetup
.Orientation = xlLandscape
.PaperSize = xlPaperA4
.Zoom = 100
End With
ActiveSheet.ResetAllPageBreaks
'Crea foglio di stampa
ActiveSheet.Copy After:=Sheets(Sheets.Count)
ActiveSheet.Cells.Clear
ActiveSheet.Name = "ZcPrint"
'
Sheets("ZcWork").Select
'
'Cerca lo zoom che mantiene l' orizzontale in 1 pagina
For ZPr = 100 To 50 Step -1
ActiveSheet.PageSetup.Zoom = ZPr
ActiveWindow.View = xlPageBreakPreview
ActiveWindow.View = xlNormalView
VPb = ActiveSheet.VPageBreaks(1).Location.Column 'ExecuteExcel4Macro("INDEX(GET.DOCUMENT(65),1)")
If VPb >= LastCol + 1 Then Exit For
Next ZPr
'Copia Work in Print
For I = 1 To Range("A65000").End(xlUp).Row Step (ActiveSheet.HPageBreaks(1).Location.Row - 3) * 2
Range("A" & I).Resize( _
ActiveSheet.HPageBreaks(1).Location.Row - 3, Range(Tab1Adr).Count).Copy Destination:= _
Sheets("ZcPrint").Range("A1").Offset((I + 1) / 2 - 1 + pippo, 0)
Range("A1").Offset(I * (ActiveSheet.HPageBreaks(1).Location.Row - 3), 0).Resize( _
ActiveSheet.HPageBreaks(1).Location.Row - 3, Range(Tab1Adr).Count).Copy Destination:= _
Sheets("ZcPrint").Range(Tab2Adr).Offset((I + 1) / 2 - 1 + pippo)
pippo = 5
Next I
Sheets("ZcPrint").Select
With ActiveSheet.PageSetup
.Orientation = xlLandscape
.PaperSize = xlPaperA4
.Zoom = ZPr
End With
End Sub
'Copia Work in Print
For I = 1 To Range("A65000").End(xlUp).Row Step (ActiveSheet.HPageBreaks(1).Location.Row - 3) * 2
Range("A" & I).Resize( _
ActiveSheet.HPageBreaks(1).Location.Row - 3, Range(Tab1Adr).Count).Copy Destination:= _
Sheets("ZcPrint").Range("A1").Offset((I + 1) / 2 - 1, 0)
Range("A1").Offset(I + ActiveSheet.HPageBreaks(1).Location.Row - 3 - 1, 0).Resize( _
ActiveSheet.HPageBreaks(1).Location.Row - 3, Range(Tab1Adr).Count).Copy Destination:= _
Sheets("ZcPrint").Range(Tab2Adr).Offset((I + 1) / 2 - 1, 0)
' set page break
Sheets("ZcPrint").HPageBreaks.Add before:=Sheets("ZcPrint").Range("A1").Offset((I + 1) / 2 - 1 + ActiveSheet.HPageBreaks(1).Location.Row - 3, 0)
Next I
Torna a Applicazioni Office Windows
Funzione CERCA ma con colonne dinamiche Autore: Paolo67met |
Forum: Applicazioni Office Windows Risposte: 2 |
Problemi di stampa file .PDF da macro. Autore: zanatta77 |
Forum: Applicazioni Office Windows Risposte: 1 |
Impostazione stampante per stampa foto personalizzate n Autore: mastino46 |
Forum: Software Windows Risposte: 4 |
Visitano il forum: Nessuno e 101 ospiti