跳到主要内容

如何在Excel中每隔x行插入分页符?

将分页符插入工作表可能很容易。 有时,需要在每X行中插入分页符以进行整齐打印,您该怎么办? 在这里,我介绍了几种解决Excel中此问题的方法。


在Excel中使用VBA每X行插入分页符

也许您不熟悉之前运行的VBA,但是通过以下步骤,您可能知道如何运行VBA在每X行中插入一个分页符。 在这里,我将每3行插入一个分页符。

1。 按 Alt + F11键 显示 Microsoft Visual Basic应用程序 窗口。

2。 在窗口中,单击 插页 > 模块 以显示新的模块窗口,然后将以下VBA代码复制到模块窗口中。

VBA:在工作表的每X行中插入分页符。

Sub InsertPageBreaks()
'Updateby20140618
Dim xLastrow As Long
Dim xWs As Worksheet
Set xWs = Application.ActiveSheet
xRow = Application.InputBox("Row", xTitleId, "", Type:=1)
xWs.ResetAllPageBreaks
xLastrow = xWs.Range("A1").SpecialCells(xlCellTypeLastCell).Row
For i = xRow + 1 To xLastrow Step xRow
    xWs.HPageBreaks.Add Before:=xWs.Cells(i, 1)
Next
End Sub

3。 点击 运行 按钮,并弹出一个对话框,供您指定要在其中插入分页符的每X行。在这里,我每3行插入分页符。 看截图:
文档插入分页符-x-rows-1

4。 点击 OK,然后将在每X行中插入一个分页符。

在活动工作表中的第(n)行中快速插入分页符

通常我们点击一​​下即可插入一个分页符 页面布局 > 休息 > 插入分页符。但这种方式在工作表中批量插入多个分页符太繁琐了,比如需要每行插入一个分页符才能在单独的页面中打印每一行。不用担心! Excel 的 Kutools 每行插入分页符 实用程序可以帮助您轻松存档!


广告插入分页符每行3

使用 Kutools for Excel 在每 x 行后批量插入分页符

如果您安装了 Kutools for Excel, 拆分为列 该实用程序可以帮助您在每x行后批量插入多个分页符,并在Excel中轻松地在每个页面中保留标题。

Kutools for Excel - 包含 300 多个 Excel 基本工具。 享受全功能 30 天免费试用,无需信用卡! 现在下载!

1。 点击 拆分为列 Kutools 加 标签。

2。 在打开的“拆分为列”对话框中,您需要:

(1)单击浏览按钮  ,在 职称范围 框,然后在指定范围内选择标题行,您将批量插入分页符。
(2)单击浏览按钮 ,在 日期范围 框,然后选择要批量插入分页符的范围。
(3)在 每页打印的行数 框中,输入一个数字。 (Tips::例如,如果您需要在每3行后插入分页符,请在框中输入3; 如果您需要在每行之后设置惰性分页符,请输入1。)
(4)在 段数 框。

3。 点击 Ok 按钮。

现在,您将看到该范围被复制到一个新的工作表中,并且每隔x行在保留范围标题的情况下添加分页符。 您还可以通过点击切换到分页预览视图 查看 > 分页预览 查看这些分页符。 请参阅下面的屏幕截图。

Kutools for Excel - 使用 300 多种基本工具增强 Excel 功能。 享受全功能 30 天免费试用,无需信用卡! 立即行动吧!


使用 Kutools for Excel 在每 x 行后插入分页符

Kutools for Excel 开发了另一个“插入分页符每行”实用程序,专门用于在每 x 行后轻松插入分页符。

Kutools for Excel - 包含 300 多个 Excel 基本工具。 享受全功能 30 天免费试用,无需信用卡! 现在下载!

1。 选择您要在每x行后插入分页符的范围,然后单击 印刷 > 每行插入分页符 Kutools 加 标签。

2。 在打开的“每行插入分页符”对话框中,指定插入分页符的行间隔,然后单击 Ok 按钮。

然后,您将看到以指定的行间隔一次插入分页符。

Kutools for Excel - 使用 300 多种基本工具增强 Excel 功能。 享受全功能 30 天免费试用,无需信用卡! 立即行动吧!


演示:在Excel中每隔x行插入分页符


Kutools for Excel:超过 300 个方便的工具触手可及! 立即开始 30 天免费试用,没有任何功能限制。 立即下载!

相关文章:

最佳办公生产力工具

🤖 Kutools 人工智能助手:基于以下内容彻底改变数据分析: 智能执行   |  生成代码  |  创建自定义公式  |  分析数据并生成图表  |  调用 Kutools 函数...
热门特色: 查找、突出显示或识别重复项   |  删除空白行   |  合并列或单元格而不丢失数据   |   不使用公式进行四舍五入 ...
超级查询: 多条件VLookup    多值VLookup  |   跨多个工作表的 VLookup   |   模糊查询 ....
高级下拉列表: 快速创建下拉列表   |  依赖下拉列表   |  多选下拉列表 ....
列管理器: 添加特定数量的列  |  移动列  |  切换隐藏列的可见性状态  |  比较范围和列 ...
特色功能: 网格焦点   |  设计图   |   大方程式酒吧    工作簿和工作表管理器   |  资源库 (自动文本)   |  日期选择器   |  合并工作表   |  加密/解密单元格    按列表发送电子邮件   |  超级筛选   |   特殊过滤器 (过滤粗体/斜体/删除线...)...
前 15 个工具集12 文本 工具 (添加文本, 删除字符,...)   |   50+ 图表 类型 (甘特图,...)   |   40+ 实用 公式 (根据生日计算年龄,...)   |   19 插入 工具 (插入二维码, 从路径插入图片,...)   |   12 转化 工具 (小写金额转大写, 货币兑换,...)   |   7 合并与拆分 工具 (高级组合行, 分裂细胞,...)   |   ... 和更多

使用 Kutools for Excel 增强您的 Excel 技能,体验前所未有的效率。 Kutools for Excel 提供了 300 多种高级功能来提高生产力并节省时间。  单击此处获取您最需要的功能...

产品描述


Office Tab 为 Office 带来选项卡式界面,让您的工作更加轻松

  • 在Word,Excel,PowerPoint中启用选项卡式编辑和阅读,发布者,Access,Visio和Project。
  • 在同一窗口的新选项卡中而不是在新窗口中打开并创建多个文档。
  • 每天将您的工作效率提高50%,并减少数百次鼠标单击!
Comments (4)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Hello, Why is it limited to number. If my spreadsheet has more than 1000 rows it will not complete the page breaks for all rows after that point.
Thanks
This comment was minimized by the moderator on the site
Dear extendoffice.com
I would like to send feedback about feature: Print > Insert Page Break Every Row.

VBA Code:
Sub InsertPageBreaks()
'Updateby20140618
Dim xLastrow As Long
Dim xWs As Worksheet
Set xWs = Application.ActiveSheet
xRow = Application.InputBox("Row", xTitleId, "", Type:=1)
xWs.ResetAllPageBreaks
xLastrow = xWs.Range("A1").SpecialCells(xlCellTypeLastCell).Row
For i = xRow + 1 To xLastrow Step xRow
xWs.HPageBreaks.Add Before:=xWs.Cells(i, 1)
Next
End Sub


When you use this function, you can only enter one variables is xRow.
So this feature will be almost useless because it is not flexible. Not all data start from Row 1, not to mention data usually is table and has Header row.

I think this feature should have another variable is xFirstRow, so that you can define the first row of data:
xFirstRow = Application.InputBox("First Row", xTitleId, "", Type:=1)

And the formula should be:
For i = xFirstRow + xRow + 1 To xLastrow Step xRow

Hopefully this feature will be upgraded in later versions.
Thanks,
Tuyen
This comment was minimized by the moderator on the site
Hi, Thanks a lot for the code. But when I press Cancel or x on the input box; the excel file crashes. Can you please help to resolve this issue.
This comment was minimized by the moderator on the site
Thanks a lot from Istanbul / Turkey :)
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations