|
原帖由 xiejiamei516 于 2010-3-20 11:05 发表
是公式出来的,还是用了宏得出来的,我只想弄清,我现在在学公式,可是这样的情况不知道怎么来的
用宏:
Sub 保存凭证()
If Range("E4").Value = 0 And Range("F4").Value = 0 Then
ms = MsgBox("凭证借方和贷方金额不能同时为 0! ", vbDefaultButton1, "凭证有错,不能保存,请修改")
End
End If
If Range("E10") <> Range("F10") Then
ms = MsgBox("凭证借贷方金额不相等!", vbDefaultButton1, "咦?!高手也会失误??!")
End
End If
If Range("C2").Value = 0 Or Range("F2").Value = 0 Then
ms = MsgBox("日期或凭证号不能为空! ", vbDefaultButton1, "大侠,你也太懒了吧!")
End
End If
If Range("A4").Value = "" Then
ms = MsgBox("凭证摘要不能为空! ", vbDefaultButton1, "大侠,你也太懒了吧!")
End
End If
ms = MsgBox("本操作将打印此凭证并保存到凭证总表(非保存工作薄!!),然后录入下一张,如果有误请到凭证总表修改! ", vbOKCancel, "警告,请谨慎操作!")
If ms = vbCancel Then
End
Else
Sheets("打印凭证").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
End If
Sheets("录入凭证").Select
ActiveWindow.SmallScroll Down:=6
Range("D17").Select
Selection.CurrentRegion.Select
Selection.AutoFilter
Selection.AutoFilter Field:=5, Criteria1:="<>"
Selection.Copy
Application.CutCopyMode = False
Selection.Copy
Application.CutCopyMode = False
Selection.Copy
Sheets("凭证总表").Select
Range("A1").Select
Selection.End(xlDown).Select
If Range("a7").Value <> 0 Then
Selection.End(xlDown).Select
End If
ActiveCell.Offset(1, 0).Range("A1").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Range("A1").Select
Sheets("录入凭证").Select
Range("D17").Select
Application.CutCopyMode = False
Selection.AutoFilter
ActiveWindow.SmallScroll Down:=-6
Application.Run "清空凭证"
End Sub
[ 本帖最后由 sendsend 于 2010-3-27 13:17 编辑 ] |
|