|
办法想出来了,读不到数据行的问题可以用对数组元素强制为文本型,你自己改一下吧
Private Sub TextBox1_Change()
Sheets("入库").ListBox1.Clear
编码 = Sheets("入库").TextBox1.Text
If 编码 = Empty Then Exit Sub
末行 = Sheets("数据库").Range("A65536").End(xlUp).Row
arr = ThisWorkbook.Sheets("数据库").Range("A1:A" & 末行)
arr = Application.Transpose(arr)
arr = Filter(arr, 编码)
If UBound(arr, 1) = -1 Then
t = Len(编码)
Sheets("入库").TextBox1.Text = Mid(编码, 1, t - 1)
Exit Sub
End If
pp = ThisWorkbook.Sheets("数据库").Range("A1:E" & 末行)
ReDim arrd(0 To UBound(arr, 1), 1 To Sheets("入库").ListBox1.ColumnCount)
p = 1
For h = 0 To UBound(arr, 1)
字符串 = arr(h)
For r = p To UBound(pp)
If 字符串 = CStr(pp(r, 1)) Then '对此句作一下修改,使数组中的元素强制为文本型。
For i = 1 To UBound(pp, 2)
arrd(h, i) = pp(r, i)
Next i
p = r + 1
Exit For
End If
Next r
Next h
Sheets("入库").ListBox1.List = arrd
End Sub
|
|