|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Sub 保存()
Dim m%, r%
Dim shtDB As Worksheet, shtInput As Worksheet, rng As Range, orderNo As String, idx As Integer, fndRng As Range
Set shtDB = Sheets("数据库")
Set shtInput = Sheets("输入")
idx = ActiveCell.Row
If idx >= 3 And ActiveSheet.Name = shtInput.Name Then
orderNo = shtInput.Cells(idx, 1)
Set fndRng = shtDB.Range("A:A").Find(orderNo)
If fndRng Is Nothing Then
If [B3] = "" Or [I3] = "" Or [J3] = "" Then MsgBox "信息没有填写完整,不能保存!": End
m = Sheets("数据库").[A65536].End(xlUp).Row + 1
r = [a9999].End(3).Row
Range("a" + CStr(idx) + ":j" & r).Copy Sheets("数据库").Range("a" & m)
MsgBox "保存成功!"
Else
MsgBox "此单已经保存过了!"
Exit Sub
End If
ActiveWorkbook.Save
End If
End Sub |
|