0

我对 VBA 代码几乎没有经验。我有一个用于库存跟踪的 excel 电子表格,我正在尝试设置一种方法来使用条形码扫描仪自动搜索电子表格内的扫描号码并提示用户添加或删除一些相关项目。

任何人都可以帮助我编写能够做到这一点的代码吗?

这里的目标是,在 B1 中扫描商品条码后,电子表格将在 C 列中搜索相关的扫描编号,然后提示您在 E 列中更新相关的“库存单位”编号。

操作完成后,B1 将再次变为空白,为下一次扫描做好准备。

任何帮助将不胜感激!

4

1 回答 1

1
Sub barcode()

Dim barcodeval As String
Dim i As Integer
Dim j As Integer
Dim quantity As Integer

i = 1
j = 3

barcodeval = Cells(1, 2)

Do While Cells(i, j) <> 0
    If barcodeval = Cells(i, j) Then
    quantity = InputBox("Update number of units in stock", "Update", "Enter new value here")
    Cells(i, j + 2) = quantity
    i = i + 1
    Else
    i = i + 1
    End If
Loop


End Sub
于 2014-12-30T19:52:43.273 回答