|
- Sub 保存() '已改
- Dim arr, brr()
- If Range("c4") = "" Or Range("j3") = "" Or Range("j2") = "" Or Range("c5") = "" Or Range("c6") = "" Or Range("e6") = "" Then
- MsgBox "表头填写不完整!"
- ' Exit Sub
- End If
- If Range("h15") = 0 Then
- MsgBox "正表中数据不全不能保存!"
- ' Exit Sub
- End If
- r = Application.CountA(Sheet1.Range("b8:b14"))
- arr = Range("b8:j" & r + 7)
- ReDim brr(1 To r, 1 To 14)
- For i = 1 To r
- brr(i, 1) = Range("j3")
- brr(i, 2) = Range("j2")
- brr(i, 3) = Range("c4")
- brr(i, 12) = Range("j17")
- brr(i, 13) = Range("j16")
- brr(i, 14) = Range("j6")
- For j = 1 To 8
- If j > 1 Then a = j + 1 Else a = j
- brr(i, j + 3) = arr(i, a)
- Next
- Next
- With Sheets("送货记录")
- Set c = Sheets("送货记录").Range("b:b").Find(Range("j2"), , , , , 1)
- If c Is Nothing Then
- i = .Range("c65536").End(3).Row + 1
- n = IIf(i = 4, 3, i)
- .Cells(n, 1).Resize(r, 14) = brr
- Else
- MsgBox "单据号为:" & Range("j2") & "的销售单信息已经保存,不能重复!"
- Exit Sub
- End If
- End With
- MsgBox "OK!保存成功!"
- End Sub
复制代码- Sub 删除() '删除 已经修改
- Application.ScreenUpdating = False
- Dim Msg&, r&, K&
- Dim hm, c As Range, c2 As Range
- hm = Range("J2")
- With Sheets("送货记录")
- Set c = Sheets("送货记录").Range("b:b").Find(hm, , , , , 1)
- If Not c Is Nothing Then
- Msg = MsgBox("确认要删除单据为" & Range("J2").Value & "的已入库信息吗?删除后将不可恢复!!", vbYesNo)
- If Msg = vbNo Then Exit Sub
- Set c2 = Sheets("送货记录").Range("b:b").Find(hm, , , , , 2)
- r = c.Row
- K = c2.Row
- .Range("a" & r & ":n" & K).Delete '删除
- End If
- End With
- Application.ScreenUpdating = True
- Application.EnableEvents = True
- MsgBox "已成功删除了单据号为:" & hm & "的信息!"
- End Sub
复制代码- Sub 查找() '已修改
- Dim arr, brr(), Msg&, tr&
- Dim hm, c As Range, c2 As Range
- Dim r&, K&, n&, b&, j&
- If Range("J2") = "" Then MsgBox "你未输入单据号!": Exit Sub
- hm = Range("J2")
- With Sheets("送货记录")
- Set c = Sheets("送货记录").Range("b:b").Find(hm, , , , , 1)
- If Not c Is Nothing Then
- Set c2 = Sheets("送货记录").Range("b:b").Find(hm, , , , , 2)
- r = c.Row '开始行号
- K = c2.Row '结束行号
- arr = .Range("a" & r & ":n" & K)
- Else
- MsgBox "没有找到" & hm & "的销售单信息"
- Exit Sub
- End If
- End With
- Range("a8:j14") = ""
- Range("c4") = arr(1, 3)
- Range("j3") = arr(1, 1)
- Range("j17") = arr(1, 12)
- Range("j16") = arr(1, 13)
- Range("j6") = arr(1, 14)
- For i = 1 To UBound(arr)
- Cells(i + 7, 1) = i
- For j = 2 To 9
- If j > 2 Then a = j + 1 Else a = j
- Cells(i + 7, a) = arr(i, j + 2)
- Next
- Next
- With Sheets("客供资料")
- Set c = Sheets("客供资料").Range("a:a").Find(Range("c4"), , , , , 1)
- If Not c Is Nothing Then
- r = c.Row
- Range("c5") = .Cells(r, 3) '地址
- Range("c6") = .Cells(r, 4) '联系人
- Range("e6") = .Cells(r, 5) '电话
- End If
- End With
- MsgBox "OK!"
- End Sub
复制代码
|
|