|
楼主 |
发表于 2011-10-14 20:16
|
显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
n520 发表于 2011-10-13 20:33
烦请楼主帮我解决下,点击入库按钮后,入库表里本来没有数据,为什么还会在数据库里生存了记录,输 ... - Sub 入库_单击()
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Application.Calculation = xlCalculationManual
- Dim irowa%, I%, MS$, RG
- If Range("E11") = "" Then MsgBox "没有输入必要的数据信息,不能添加此笔记录!" _
- & Chr(13) & Chr(13) & "请输入相应的数据!", 1 + 64, "普鑫软件工程": Exit Sub
- irowa = Sheet6.Range("E65536").End(xlUp).Row + 1
- For I = 2 To irowa
- If Range("K8").Value = Sheet6.Range("d" & I).Value Then
- If MsgBox("已经有了单据" & Range("K8").Value & "的信息,是否录入?", vbYesNo, "提示") = vbNo Then Exit Sub
- End If
- Next
- With Sheet6
- n = Range("E11").End(xlDown).Row
- If n = 17 Then n = 16
- For I = 11 To n
- .Unprotect
- .Range("e" & irowa & ":I" & irowa) = Range("E" & I & ":I" & I).Value
- .Range("a" & irowa & ":a" & irowa) = Right(Application.WorksheetFunction.Substitute([C5], " ", ""), 5)
- .Range("b" & irowa & ":b" & irowa) = Range("E8").Value
- .Range("c" & irowa & ":c" & irowa) = Range("H8").Value
- .Range("d" & irowa & ":d" & irowa) = Range("K8").Value
- .Range("J" & irowa & ":J" & irowa) = Range("J" & I & ":J" & I).Value
- .Range("L" & irowa & ":L" & irowa) = Range("K" & I & ":K" & I).Value
- .Range("M" & irowa & ":M" & irowa) = Range("K19").Value
- .Protect
- irowa = irowa + 1
- Next
- End With
- Range("E8") = ""
- Range("E11:E16").ClearContents
- 'Range("F11:I16").Value = ""
- Range("J11:K16").Value = ""
- Range("K19").Value = ""
- Range("H8") = Date
- Set RG = Sheets("入库单").Range("K8")
- If Format(Range("H8"), "YYYYMMDD") <> Mid(RG, 3, 8) Then
- RG.Value = "RK" & Format(Range("H8"), "YYYYMMDD") & "0001"
- Else
- RG.Value = "RK" & Format(Range("H8"), "YYYYMMDD") & Format(Right(RG.Value, 4) + 1, "0000")
- End If
- ActiveSheet.Protect
- Application.Calculation = xlCalculationAutomatic
- Application.ScreenUpdating = True
- Application.DisplayAlerts = True
- End Sub
复制代码 |
|