跳到主要内容

如何在Excel中每个已打印页面的底部重复打印行?

默认情况下,Excel为用户提供了在顶部重复打印行的功能。 但是在某些情况下,您可能希望在页面底部(顶部除外)重复打印行。 本文将向您展示一些小技巧。

使用VBA代码在底部重复打印行


使用VBA代码在底部重复打印行

您可以运行下面的VBA代码,将指定的行插入每个页面的页脚。 然后,您可以在Excel中每个打印页面的底部重复打印此行。

1。 按 其他 + F11 同时打开 Microsoft Visual Basic应用程序 窗口。

2.在 Microsoft Visual Basic应用程序 窗口对话框,单击 插页 > 模块。 然后将下面的VBA代码复制并粘贴到“模块”窗口中。

VBA代码:将指定的行插入每个打印页面的页脚

Sub MyFooter()
	Dim xTxt As String
	Dim xAddress As String
	Dim xRg As Range
	Dim xCell As Range
	On Error Resume Next
	xAddress = ActiveWindow.RangeSelection.Address
	Set xRg  = Application.InputBox("Select the row you will insert repeatedly at the bottom:", "Kutools for Excel", xAddress, , , , , 8)
	If xRg Is Nothing Then Exit Sub
		For Each xCell In xRg
			xTxt = xTxt & xCell.Value & " "
		Next
		ActiveSheet.PageSetup.LeftFooter = xTxt
	End Sub

3。 按 F5 键来运行代码。然后弹出一个 Kutools for Excel 对话框,请在每个打印页面的底部选择需要重复打印的行,然后单击 OK 按钮。

现在,将指定的行内容添加到当前工作表中每个打印页面的页脚中。 您可以开始打印工作表。

备注:如果要在整个工作簿的每一页底部重复打印所选内容,可以应用页脚功能将内容插入所有工作表的页脚中。


在Excel中的第n行中轻松重复标题行:

Kutools for Excel's 插入标题行 实用程序可以帮助您快速将标题行插入Excel中选定范围内的第n行之前,如下所示。
立即下载并试用! (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 (11)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Hi,

I've been trying to use the above code but when I try to print te code it doesn't work. I followed all above steps and it doesn't give me any errors.
I'm using office 365. Any tips ?

Thanks in advance,
This comment was minimized by the moderator on the site
Hi Tim,
Hi, the selected row will be inserted into the page footer, you need to switch to the Page Layout view to check for the result. Thank you for your comment.
This comment was minimized by the moderator on the site
Hi,

When I start the macro and select the wished rows it doesn't work when I try to print. What can this be?
Using office 365.

Thanks,
This comment was minimized by the moderator on the site
Hi,
I am trying a few times but it's not working. Please advise.
This comment was minimized by the moderator on the site
Good day,
Thank you for your comment. Which Office version do you use?
This comment was minimized by the moderator on the site
If I may, I use Office365 but its not working. Have tried putting the view on Page Layout Mode to no avail. Hope you can help. Thanks.
This comment was minimized by the moderator on the site
Thank you So Muchhhh...
It helped me very much.
This comment was minimized by the moderator on the site
Thanks for sharing. is any possibility of VBA code to repeated footer same as with "print titles" option including lines and auto page number. if possible please help me.
This comment was minimized by the moderator on the site
Thanks for sharing the macro to repeat the rows at the bottom of the page. Can this Macro be modified to Repeat selected Rows with the format as well.. In the provided Macro only Values are repeated at the bottom of each page, I am looking forward to copy the format as well at the bottom of the page..
This comment was minimized by the moderator on the site
Thanks a lot. This macro serves my purpose, Thanks to the creator and the person who had shared Macro
This comment was minimized by the moderator on the site
Thanks for Macro sharing. It serves my purpose. Thanks a lot.
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations