如何在打印页面中设置数字行(excel VBA) [英] How to set the number row in a print page(excel VBA)

查看:296
本文介绍了如何在打印页面中设置数字行(excel VBA)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我有关于打印excel VBA的问题,



我的excel文件有200个数据行,我希望每个打印页面只包含最多50行,所以我将有4print页面。但是我不能为此编码。



请帮帮我



提前感谢

Hi all, I have a problem about print in excel VBA,

My excel file have 200 data row and I want each print page only contain maximum 50 row, So I will have 4print page. But I can't code for this.

Please help me

Thank in advance

推荐答案

试试这个:

Try this:
Option Explicit

Sub test()
Dim i As Integer, j As Integer
Dim wsh As Worksheet

Set wsh = ThisWorkbook.Worksheets(1)

'remove all page breaks
wsh.ResetAllPageBreaks
'enable autoajusting
wsh.PageSetup.Zoom = False
'set new area
wsh.PageSetup.PrintArea = "A:J"
'set paper orientation
wsh.PageSetup.Orientation = xlLandscape
'add horizontal page break on every 50. row
For i = 50 To 200 Step 50
    j = j + 1
    wsh.HPageBreaks.Add wsh.Range("A" & i + 1)
Next i


wsh.PageSetup.FitToPagesWide = 1
wsh.PageSetup.FitToPagesTall = j

wsh.PrintPreview
Set wsh = Nothing

End Sub


这篇关于如何在打印页面中设置数字行(excel VBA)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆