excel - 如何在超过 60000 行的文本框中快速显示结果
问题描述
我有 Excel 数据库,我只想输入标签号,我会自动在文本框中显示结果...但是需要 30 秒才能显示结果
Private Sub cmdSearch_Click()
Dim x As Long
Dim y As Long
x = Sheets("Clients").Range("A" & Rows.Count).End(xlUp).Row
For y = 1 To x
If Sheets("Clients").Cells(y, 1).Text = TextBox1.Value Then
TextBox1.Text = Sheets("Clients").Cells(y, 1)
TextBox4.Text = Sheets("Clients").Cells(y, 3)
TextBox5.Text = Sheets("Clients").Cells(y, 4)
TextBox10.Text = Sheets("Clients").Cells(y, 5)
TextBox11.Text = Sheets("Clients").Cells(y, 6)
TextBox12.Text = Sheets("Clients").Cells(y, 7)
TextBox13.Text = Sheets("Clients").Cells(y, 8)
End If
Next y
End Sub
解决方案
Match
相当快
Private Sub cmdSearch_Click()
Dim m As VARIANT
With Sheets("Clients")
m = Application.Match(TextBox1.Value, .Columns(1), 0)
If not iserror(m) then
TextBox4.Text = .Cells(m, 3)
TextBox4.Text = .Cells(m, 4)
'etc
end if
end with
End Sub
推荐阅读
- javascript - 如何使用 Angular 6 设置永久迭代
- objective-c - Xcode 10 Objective-C #import 文件名完成不起作用
- javascript - 将外部 JavaScript(来自 cdn)捆绑到 React 组件中
- scala - Spark sql group by和sum改变列名?
- java - 我如何用java语言对数据进行分组和转换
- css - 带有 iframe 的引导模式仅在 iPhone 上不允许垂直滚动
- java - 在我的代码中出现错误如何解决?
- node.js - 快速选择机器人框架
- java - 为 SPA 应用程序集成 openid 连接的最佳方式
- javascript - 自定义 Mozilla Firefox 滚动条