|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Private Sub CommandButton1_Click()
If TextBox1.Text = "" Or TextBox2.Text = "" Or TextBox3.Text = "" Or TextBox4.Text = "" Or TextBox5.Text = "" Or TextBox6.Text = "" Or TextBox7.Text = "" Then
MsgBox "请将备件信息填写完整!"
Exit Sub
End If
Dim xrow As Integer
ar = Array(TextBox1.Text, TextBox2.Text, TextBox3.Text, TextBox4.Text, TextBox5.Text, TextBox6.Text, TextBox7.Text)
arr = Array(TextBox6.Text, TextBox2.Text, TextBox3.Text, TextBox7.Text, TextBox4.Text)
With Sheets("入库记录")
xrow = .Cells(Rows.Count, 1).End(xlUp).Row + 1
.Cells(xrow, "A").Resize(1, 7) = ar
End With
Dim d As Object
Set d = CreateObject("scripting.dictionary")
With Sheets("库位表")
ws = .Cells(Rows.Count, 1).End(xlUp).Row
If ws < 2 Then
.Cells(ws + 1, "A").Resize(1, 5) = arr
Else
br = .Range("a1:g" & ws)
For i = 2 To UBound(br)
If Trim(br(i, 1)) <> "" And Trim(br(i, 2)) <> "" And Trim(br(i, 3)) <> "" And Trim(br(i, 4)) <> "" Then
s = Trim(br(i, 1)) & "|" & Trim(br(i, 2)) & "|" & Trim(br(i, 3)) & "|" & Trim(br(i, 4))
d(s) = i
End If
Next i
ss = Trim(arr(0)) & "|" & Trim(arr(1)) & "|" & Trim(arr(2)) & "|" & Trim(arr(3))
m = d(ss)
If m <> "" Then
.Cells(m, 5) = .Cells(m, 5) + arr(4)
ElseIf m = "" Then
.Cells(ws + 1, "A").Resize(1, 5) = arr
End If
End If
End With
Sheets("入库记录").Activate
End Sub
|
|