excel - 打印时更新的 Excel 中的页码
解决方案
我认为,没有直接的方法可以在打印时增加单元格的价值。但是你可以使用VBA,如何使用VBA?你可以搜索一下。我的问题,打印区域在哪里?我假设打印区域来自同一张纸。
这里的代码:
Sub forprint()
Dim nPrint As Variant
Dim i, n As Long
On Error Resume Next
n = Range("F1").Value
nPrint = Application.InputBox("Number of Copy", "Print")
If TypeName(nPrint) = "Boolean" Then Exit Sub
If (nPrint = "") Or (Not IsNumeric(nPrint)) Or (nPrint < 1) Then
MsgBox "Enter number only & minimum 1 copy", vbExclamation, "Wrong character or value!"
Else
Application.ScreenUpdating = False
For i = 1 To nPrint
ActiveSheet.Range("F1").Value = n + nPrint
Sheets("Sheet1").PrintOut '<< change Sheet1 to your sheet with the printarea
Next
Application.ScreenUpdating = True
End If
End Sub
在 VBA 窗口中插入模块。单击插入>>模块,然后将代码粘贴到模块窗口中,然后按 F5 运行代码。
推荐阅读
- ruby-on-rails - Ruby - 如何访问已解析 json 中的键值
- swift - 标签不会在键入时复制文本 - 尝试了许多解决方案(MacOS 应用程序)
- c# - 16 位 11025 单声道 WAVE 数据中的一个样本值
- java - JavaFX 11.0.2 不适用于 Intellij (java 11)
- wpf - 将非静态参数传递给 CollectionViewSource 中的过滤器
- mesh - 如何使用 Meshlab 查看导入的 OBJ 文件中的边和/或属的总数?
- java - DDD | JPA - 可能涉及牺牲设计以提高效率的设计问题
- ios - Apple 批准替换 URLWithString:@"App-prefs:root=FACEBOOK"];
- sql - 切换列值
- python - 如何在 Python 中进行异步 gRPC 调用?