|
Sub 修改打印() '[G2]不允许修改
Sheets("批办单").Activate
Dim rng As Range, cel As Range, cl As Range, k&, n&
Set rng = [g2,e3,c3,c4,e4,g3,g4,c5,c10]
With Sheets("数据库")
Set cel = .[a:a].Find([g2], , , 1)
If Not cel Is Nothing Then
k = cel.Row
For Each cl In rng
n = n + 1
.Cells(k, n) = cl.Value
Next
End If
Range("b1:g14").Select
Selection.PrintOut Copies:=1, Collate:=True
End With
MsgBox "修改保存、正在打印!"
End Sub
====================================
Sub 提交打印()
Application.ScreenUpdating = False
Dim n%, m%, x%, y%, k%
On Error GoTo 100
If Sheets("数据库").[a:a].Find([g2]) = [g2] Then
MsgBox "此单已经保存过了!"
Else
100:
If [c3] = "" Or [c4] = "" Or [e3] = "" Or [e4] = "" Or [c5] = "" Or [c10] = "" Then MsgBox "信息没有填写完整,不能保存!": End
m = Sheets("数据库").[A65536].End(xlUp).Row + 1
With Sheets("数据库")
.Cells(m, "A").Value = [g2] '编号
.Cells(m, "B").Value = [e3] '收文日期
.Cells(m, "C").Value = [c3] '发文单位
.Cells(m, "D").Value = [c4] '文号
.Cells(m, "E").Value = [e4] '收文号
.Cells(m, "F").Value = [g3] '紧急程度
.Cells(m, "G").Value = [g4] '密级
.Cells(m, "H").Value = [c5] '文件标题
.Cells(m, "I").Value = [c10] '拟办意见
Range("b1:g14").Select
Selection.PrintOut Copies:=1, Collate:=True
End With
MsgBox "提交成功、正在打印!"
End If
ActiveWorkbook.Save
Application.ScreenUpdating = True
End Sub
现在是两个按键,想只通过提交打印实现将新增保存、修改保存两功能合二为一,菜鸟一枚、求大神支援!!!
|
|