如何在excel中做一个VBA程序,扫描条码时只读取条码的前11位然后查找到excel中相同的数据。

2024-12-18 20:23:17
推荐回答(1个)
回答1:

Sub dk()
a = "12345678901234"
b = Mid(a, 1, 11)
Range("a3") = b
Set c = Range("a1:a65356").Find(b, LookIn:=xlValues)
If Not c Is Nothing Then
Debug.Print c.Address
Do While True
d = InStr(2, c.Address, "$")
e = Mid(c.Address, d + 1)
If d > 1 Then Exit Do
Loop
Range("h" & e) = a
End If
End Sub