Может кто-нибудь сказать мне, почему приведенный ниже код не работает быстрее, когда я использую массив? Кажется, для запуска требуется 10 минут или больше, что странно, потому что вчера без массива может потребоваться минута или две
Sub populateHRData9()
hrArray = Worksheets("HR_Report").Range("A1").CurrentRegion.Value
Set report = ActiveWorkbook.Worksheets("Report")
For x = 2 To report.UsedRange.Rows.Count
If report.Cells(x, 1) = "" Then
End If
Next x
For j = 2 To UBound(hrArray, 1)
If hrArray(j, 42) <> "United Kingdom" Or hrArray(j, 42) <> "France" Or
hrArray(j, 42) <> "Ireland" Or hrArray(j, 42) <> "Italy" Or hrArray(j, 42) <>
"Netherlands" Or hrArray(j, 42) <> "Spain" Or hrArray(j, 42) <> "Sweden" Or
hrArray(j, 42) <> "Germany" Or hrArray(j, 42) <> "Austria" Then
If hrArray(j, 10) = "WEALTH MANAGEMENT" Or hrArray(j, 10) = "INTELLIGENT
DIGITAL SOLUTIONS" Then
If hrArray(j, 18) = "Administrative Asst - AM Investors/WM Solutions" Or
hrArray(j, 18) = "Administrative Asst (Sales Service)" Or hrArray(j, 18) =
"Administrative Asst (Sales/CA Support)" Or hrArray(j, 18) = "Client Service
Total" Or hrArray(j, 18) = "Communications" Or hrArray(j, 18) = "Fiduciatary"
Or hrArray(j, 18) = "Front Office Interns" Or hrArray(j, 18) = "Investments"
Or hrArray(j, 18) = "Investors Service - ex Program Analysts" Or hrArray(j,
18) = "JPMS Financial Advisors" Or hrArray(j, 18) = "JPMS Solutions" Or
hrArray(j, 18) = "Marketing and Events" Or hrArray(j, 18) = "Mortgage
Advisory" Or hrArray(j, 18) = "Origination/Client Manager" Or hrArray(j, 18)
= "Other" Or hrArray(j, 18) = "Solutions - Program Analyst" Or hrArray(j, 18)
= "Summer Intern" Or hrArray(j, 18) = "Supervisory Management" Or hrArray(j,
18) = "WM Bankers" Or hrArray(j, 18) = "WM Capital Advisors" _
Or hrArray(j, 18) = "WM Investors" Or hrArray(j, 18) = "WM MM/RH/PL" Or
hrArray(j, 18) = "WM Prosectors" Or hrArray(j, 18) = "WM Trusts Officers" Or
hrArray(j, 18) = "WM Wealth Advisors" Or hrArray(j, 18) = "WMOC" Then
report.Cells(x, 1) = hrArray(j, 3)
x = x + 1
End If
End If
End If
Next j
End Sub
Извините за несколько операторов if. Если пропускал "Великобритания", когда я использовал или. Вот код, который у меня был до и после перезагрузки компьютера, он снова работает быстро.
Sub populateHRData9()
Set report = ActiveWorkbook.Worksheets("Report")
Set hr = ActiveWorkbook.Worksheets("HR_Report")
For x = 2 To report.UsedRange.Rows.Count
If report.Cells(x, 1) = "" Then
End If
Next x
For j = 2 To hr.UsedRange.Rows.Count
If hr.Cells(j, 42) <> "United Kingdom" Then
If hr.Cells(j, 42) <> "France" Then
If hr.Cells(j, 42) <> "Ireland" Then
If hr.Cells(j, 42) <> "Italy" Then
If hr.Cells(j, 42) <> "Netherlands" Then
If hr.Cells(j, 42) <> "Spain" Then
If hr.Cells(j, 42) <> "Sweden" Then
If hr.Cells(j, 42) <> "Germany" Then
If hr.Cells(j, 42) <> "Austria" Then
If hr.Cells(j, 10) = "WEALTH MANAGEMENT" Or hr.Cells(j, 10) =
"INTELLIGENT DIGITAL SOLUTIONS" Then
If hr.Cells(j, 18) = "Administrative Asst - AM Investors/WM Solutions"
Or hr.Cells(j, 18) = "Administrative Asst (Sales Service)" Or hr.Cells(j,
18) = "Administrative Asst (Sales/CA Support)" Or hr.Cells(j, 18) = "Client
Service Total" Or hr.Cells(j, 18) = "Communications" Or hr.Cells(j, 18) =
"Fiduciatary" Or hr.Cells(j, 18) = "Front Office Interns" Or hr.Cells(j, 18)
= "Investments" Or hr.Cells(j, 18) = "Investors Service - ex Program
Analysts" Or hr.Cells(j, 18) = "JPMS Financial Advisors" Or hr.Cells(j, 18)
= "JPMS Solutions" Or hr.Cells(j, 18) = "Marketing and Events" Or
hr.Cells(j, 18) = "Mortgage Advisory" Or hr.Cells(j, 18) =
"Origination/Client Manager" Or hr.Cells(j, 18) = "Other" Or hr.Cells(j, 18)
= "Solutions - Program Analyst" Or hr.Cells(j, 18) = "Summer Intern" Or
hr.Cells(j, 18) = "Supervisory Management" Or hr.Cells(j, 18) = "WM Bankers"
Or hr.Cells(j, 18) = "WM Capital Advisors" _
Or hr.Cells(j, 18) = "WM Investors" Or hr.Cells(j, 18) = "WM MM/RH/PL"
Or hr.Cells(j, 18) = "WM Prosectors" Or hr.Cells(j, 18) = "WM Trusts
Officers" Or hr.Cells(j, 18) = "WM Wealth Advisors" Or hr.Cells(j, 18) =
"WMOC" Then
report.Cells(x, 1) = hr.Cells(j, 3)
x = x + 1
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
Next j
End Sub