Может ли кто-нибудь объяснить мне, почему мой макрос выполняется намного быстрее в Microsoft Visual Basic (> 10 секунд), чем в листе Excel с кнопкой (<10 минут ...) </p>
код макроса.Спасибо.
Sub RecoverData()
Application.ScreenUpdating = False
Dim BI As Workbook
Dim supplier As Range
Dim filter As Range
Dim lastRow As Long
'## Open both workbooks first:
Application.AskToUpdateLinks = False
Application.DisplayAlerts = False
Set BI = Workbooks.Open(Application.ActiveWorkbook.Path & "\data.xlsx")
With BI.Sheets("Panel") ' reference source sheet
Set supplier = .Rows(2).Find(ThisWorkbook.Sheets("Parameters").Range("B1").Value, lookat:=xlWhole) ' try searching wanted header in BI
Set filter = .Rows(2).Find(ThisWorkbook.Sheets("Parameters").Range("B2").Value, lookat:=xlWhole) ' try searching wanter header in BI
lastRow = .Range(Col_Letter(Range(supplier.Address).Column) & .Rows.Count).End(xlUp).Row ' find the last row with data in column A
If Not supplier Is Nothing Then ' if found
Range("A1").AutoFilter Field:=Range(filter.Address).Column, Criteria1:=Array("P01*", "P02*"), Operator:=xlFilterValues ' find the column to filter on
Range("E3:E" & lastRow).SpecialCells(xlCellTypeVisible).Copy ThisWorkbook.Sheets("Feuil2").Range("A1") ' find the column to get value from
ThisWorkbook.Sheets("Feuil2").Range("A1").CurrentRegion.RemoveDuplicates Columns:=1
.AutoFilterMode = False
Else
MsgBox "Column Name Not Found"
End If
End With
BI.Close savechanges:=False
Application.ScreenUpdating = True
Range("A5").Font.Color = vbGreen
End Sub