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
Ordinare colonne sulla stessa riga se stesso contenuto Autore: Ricky0185 |
Forum: Applicazioni Office Windows Risposte: 10 |
Stabilire righe e colonne da mostrare a schermo Autore: Ricky0185 |
Forum: Applicazioni Office Windows Risposte: 10 |
Problemi di stampa su carta adesiva lucida con Epson Et 2850 Autore: lukarello7 |
Forum: Discussioni Risposte: 5 |
SOMMARE DUE VALORI IN DUE COLONNE DIVERSE Autore: millennia80 |
Forum: Applicazioni Office Windows Risposte: 1 |
Visitano il forum: Nessuno e 25 ospiti