|
- Private Sub Worksheet_Change(ByVal Target As Range)
- Application.EnableEvents = False
- Dim arr, brr, ar, i%, x, tt, d As Object
- tt = Timer
- If Target.CountLarge > 1 Then Exit Sub
- If Target.Row = 1 Then Exit Sub
- If Target.Column = 1 Then
- x = Target.Value
- If Len(x) <> 13 Then
- Target.Offset(0, 2) = "书号错": Application.EnableEvents = True: Exit Sub
- Else
- If Left(x, 3) = "978" Or Left(x, 3) = "979" Then
- Set d = CreateObject("Scripting.Dictionary")
- With Sheets("参展")
- arr = .[a1].CurrentRegion
- For i = 2 To UBound(arr)
- d(arr(i, 1)) = i
- Next
- End With
- With Sheets("现场扫书")
- If d.exists(x) Then
- brr = .[a1].CurrentRegion
- For i = 2 To UBound(brr)
- d("@" & brr(i, 1)) = d("@" & brr(i, 1)) + 1
- Next
- ar = Target.Resize(1, 10)
- ar(1, 2) = arr(d(x), 12) '把找书订户复制过来
- ar(1, 3) = arr(d(x), 13) '把找书数量复制过来
- ar(1, 4) = arr(d(x), 7) '把参展数量复制过来
- ar(1, 5) = arr(d(x), 8) '把销售数量复制过来
- ar(1, 6) = arr(d(x), 9) '把已转移数量复制过来
- ar(1, 7) = arr(d(x), 10) '把回库数量复制过来
- ar(1, 8) = 1 '扫书数量记录为1
- ar(1, 9) = arr(d(x), 6) '把参展出库的书店分类复制过来
- ar(1, 10) = .[k1] '将J1单元格的架位复制到架位号列内
- If d("@" & x) > 1 Then ar(1, 2) = "重复"
- If d("@" & x) > ar(1, 7) Then MsgBox "盘点数量大于回库,查看是否多书!"
- Target.Resize(1, 10) = ar
- Else
- Target.Offset(0, 7) = 1
- Target.Offset(0, 9) = .[k1]
- Target.Offset(0, 1) = "查无" '如果参展内没有,标记查无
- Target.Offset(0, 1).Speak '朗读查无
- End If
- End With
- Set d = Nothing
- Else
- Target.Offset(0, 2) = "书号错"
- End If
- End If
- End If
- Target.Offset(0, 2).Speak
- MsgBox "OK! 运行时间:" & Format(Timer - tt, "0.00000") & "秒"
- Application.EnableEvents = True
- End Sub
复制代码 |
|