excel - 从数组中的大数据填充列表框
问题描述
我正在尝试为如何填充列表框的问题找到解决方案。问题是数据太大(100 万行和大约 20 列)。此代码适用于少量数据,但对于大数据,代码搜索过程大约需要 25 秒
Private Sub TextBox14_AfterUpdate()
Dim a, b(), temp, ws As Worksheet, i As Long, n As Long, c As Long
Set ws = ThisWorkbook.Worksheets("Data")
Me.ListBox1.Clear
temp = Me.TextBox14.Value
c = ComboBox1.ListIndex
If (c = -1) + (temp = "") Then MsgBox "Specify Search Column First And Make Sure TextBox Is Not Empty", vbExclamation: Exit Sub
a = ws.Range("A1:S" & ws.Cells(Rows.Count, 1).End(xlUp).Row).Value
ReDim b(1 To 100000)
b(1) = Application.Index(a, 1, 0)
For i = 2 To UBound(a, 1)
If CStr(a(i, c + 1)) Like "*" & temp & "*" Then
n = n + 1
b(n) = Application.Index(a, i, 0)
End If
Next i
If n > 0 Then
ReDim Preserve b(1 To n)
If n = 1 Then
Me.ListBox1.Column = Application.Index(b, 0, 0)
Else
Me.ListBox1.List = Application.Index(b, 0, 0)
End If
End If
End Sub
我怎样才能让这个大数据以测试方式运行?
解决方案
推荐阅读
- editing - 无法在 Marlin 中编辑配置文件
- reactjs - 如何使用 fetch 从 400 错误请求中捕获响应 JSON?
- python - 脸书 API | AdInsights 对比 广告帐户级速率限制
- javascript - 我不确定为什么我不能使用 .forEach() 更改我的 Class 对象的 .value 值
- javascript - 将变量从 Express 服务器传递到 React 前端
- rust - 为什么 Rust 的 Cargo 不认为 0.8.3 版本具有与 0.9.0 版本兼容的 API?
- java - 几乎递增的序列编码问题
- powershell - 除了 Get-Credential,还有其他方法可以在 Powershell 中请求凭据吗?
- pyspark - pyspark:是否可以在一个结构中创建缺少元素的数组
- java - 获取 JavaFX 窗口的像素颜色