Excel vba代码在一列中找到值很慢,我如何使它更快



我的vba代码下面,如何做得更快?(obs:我有+- 33000行值)我从产品搜索代码到我的公司,我需要帮助来做得更快。

Private Sub TextBox1_Enter()
Dim FindString As String
Dim Rng As Range
FindString = TextBox1.Text
If Trim(FindString) <> "" And Len(TextBox1.Text) = 6 Then
   With Sheets("CADMAT").Range("B:B") 'searches all of column B
        Set Rng = .Find(What:=FindString, _
                    After:=.Cells(.Cells.Count), _
                    LookIn:=xlValues, _
                    LookAt:=xlWhole, _
                    SearchOrder:=xlByRows, _
                    SearchDirection:=xlNext, _
                    MatchCase:=False)
    If Not Rng Is Nothing Then
        Dim ultimalinha As Object
        Set ultimalinha = Plan3.Range("A35565").End(xlUp)
        ultimalinha.Offset(1, 0).Value = TextBox1.Text
        ultimalinha.Offset(1, 1).Value = TextBox2.Text
        TextBox1.Text = ""
        TextBox2.Text = ""
        TextBox1.SetFocus
    Else
        MsgBox "Produto não existe na tabela!" 'value not found
        TextBox1.Text = ""
        TextBox2.Text = ""
        TextBox1.SetFocus
    End If
End With
End If
End Sub

选项显式

Private Sub TextBox1_Enter()

应用程序。ScreenUpdating = False

这里的代码…

应用程序。ScreenUpdating = True

结束子

相关内容

  • 没有找到相关文章

最新更新