比如今天1号,我在B21处输入编码222222,则B6单元格数量就是1,输入两次数量就变成2, 日期要是2号,同样操作,则D6增加数据,如果是在出库单元格输入条码,则数据就自动减去
再加一个功能,e21单元格输入一串编码确定之后,编码就消失了,方便下次输入,不用每次都要先删除旧的编码,再重新输入新编码
追答Private Sub Worksheet_Change(ByVal Target As Range)
Dim tr, tc
tr = Target.Row
tc = Target.Column
On Error Resume Next '
Application.DisplayAlerts = False
If tr = 21 And tc = 2 Then
x = WorksheetFunction.Match([B21], Range("a1:a19"), 0)
y = Day(Now) & "号"
N = WorksheetFunction.Match(y, Range("a3:aZ3"), 0)
MsgBox "货号:" & Cells(x, "A") & "日期:" & y & "入库"
Cells(x, N) = Cells(x, N) + 1
[B21] = ""
End If
'----
If tr = 21 And tc = 5 Then
x1 = WorksheetFunction.Match([E21], Range("a1:a19"), 0)
y1 = Day(Now) & "号"
N1 = WorksheetFunction.Match(y1, Range("a3:aZ3"), 0)
MsgBox "货号:" & Cells(x1, "A") & "日期:" & y1 & "出库"
Cells(x1, N1 + 1) = Cells(x1, N1 + 1) - 1
[E21] = ""
End If
End Sub
怎么才能输入编码之后,按空格键不要让他跳到下一格呢,依然固定在B21 或 E21单元格里
追答[B21] = ""
修改为
[B21] = ""
[B21] .SELECT
出错了,显示无效或不合格的引用
追答Private Sub Worksheet_Change(ByVal Target As Range)
Dim tr, tc
tr = Target.Row
tc = Target.Column
On Error Resume Next
If tr = 21 And tc = 2 Then
x = WorksheetFunction.Match([B21], Range("a1:a19"), 0)
y = Day(Now) & "号"
N = WorksheetFunction.Match(y, Range("a3:aZ3"), 0)
MsgBox "货号:" & Cells(x, "A") & "日期:" & y & "入库"
Cells(x, N) = Cells(x, N) + 1
[B21] = ""
[B21].Select
End If
'----
If tr = 21 And tc = 5 Then
x1 = WorksheetFunction.Match([E21], Range("a1:a19"), 0)
y1 = Day(Now) & "号"
N1 = WorksheetFunction.Match(y1, Range("a3:aZ3"), 0)
MsgBox "货号:" & Cells(x1, "A") & "日期:" & y1 & "出库"
Cells(x1, N1 + 1) = Cells(x1, N1 + 1) - 1
[E21] = ""
[E21].Select
End If
End Sub
好像不行,输完编码按回车键还是会跳到下一格
追答[E21].Select
这个就是 定位到E21
你这个应该是扫条码的
这边测试没问题
我在中间加一个销售,录入出库时,那出库的数据就跑到销售下面去了,需要哪里修改一下
+1
修改为+2
因为日期是合并单元格
这样没法实现?
追答这样能做到,但是一丁点错误都不能犯,完全没有订正的机会。
追问那如何做呢