hadoan-pap
Thành viên tiêu biểu

- Tham gia
- 8/7/15
- Bài viết
- 461
- Được thích
- 20
Chào các bạn và anh chị.
Em có đoạn code như bên dưới, nhưng có vẻ nó chạy hơi chậm do k dung mảng... Moi ng có thể giúp em làm thế nào để tang tốc độ chạy code đó đc k ạ?
Ví dụ dùng mảng cũng đc.
Em xin cảm ơn!
With Application
.Interactive = False
.EnableEvents = False
.ScreenUpdating = False
.Calculation = xlCalculationManual
End With
Dim i As Integer
Dim j As Integer
If Sheet2.Cells(18, 3) <> 0 Then
If Sheet2.Cells(18, 3) < Sheet2.Cells(6, 9) Then
MsgBox "The Plan data could not smaller than AP date.", vbInformation, "Warning......!"
Sheet2.Cells(18, 3).Interior.ColorIndex = 45
Else
Sheet2.Cells(18, 3).Interior.ColorIndex = 2
End If
End If
If Sheet2.Cells(10, 2) = "General Expenditure" And Sheet2.Cells(10, 4) = "Purchase" Then
If Sheet2.Cells(10, 6) = "Tangible Goods" Or Sheet2.Cells(10, 6) = "Intangible Goods" Then
If Sheet2.Cells(25, 8) <> 0 And Sheet2.Cells(25, 8) > 30000000 Then
MsgBox "Check Whether FA Or Not.", vbInformation, "Warning......!"
Sheet2.Cells(25, 8).Interior.ColorIndex = 45
Else
Sheet2.Cells(25, 8).Interior.ColorIndex = 2
End If
End If
End If
If Sheet2.Cells(32, 4) <> " " And Sheet2.Cells(32, 4) > 2300000 Then
MsgBox "Over Limited Amount.", vbInformation, "Warning...Entertainment Fee Only.!"
Sheet2.Cells(32, 4).Interior.ColorIndex = 45
Else
Sheet2.Cells(32, 4).Interior.ColorIndex = 2
End If
' check chu ky
If Sheet2.Cells(10, 2) = "General Expenditure" Or Sheet2.Cells(10, 2) = "Tools & equipments" Or Sheet2.Cells(10, 2) = "Others" Then
If IsEmpty(Sheets("Approval sheet Form").Range("H25")) = False Then ' Kiem tra dieu kien H25 co du lieu
If Sheet2.Cells(25, 8).Value < 10000000 Then
Sheet2.Cells(44, 7).Interior.ColorIndex = 48
Sheet2.Cells(44, 7) = "Not Applicable"
Sheet2.Cells(44, 8).Interior.ColorIndex = 48
Sheet2.Cells(44, 8) = "Not Applicable"
Sheet2.Cells(44, 9).Interior.ColorIndex = 48
Sheet2.Cells(44, 9) = "Not Applicable"
ElseIf Sheet2.Cells(25, 8).Value > 10000000 And Sheet2.Cells(25, 8).Value < 250000000 Then
Sheet2.Cells(44, 7).Interior.ColorIndex = 48
Sheet2.Cells(44, 7) = "Not Applicable"
Sheet2.Cells(44, 8).Interior.ColorIndex = 2
Sheet2.Cells(44, 8) = " "
Sheet2.Cells(44, 9).Interior.ColorIndex = 2
Sheet2.Cells(44, 9) = " "
Else
Sheet2.Cells(44, 7).Interior.ColorIndex = 2
Sheet2.Cells(44, 7) = " "
Sheet2.Cells(44, 8).Interior.ColorIndex = 2
Sheet2.Cells(44, 8) = " "
Sheet2.Cells(44, 9).Interior.ColorIndex = 2
Sheet2.Cells(44, 9) = " "
End If
End If
Else
Sheet2.Cells(44, 7).Interior.ColorIndex = 2
Sheet2.Cells(44, 7) = " "
Sheet2.Cells(44, 8).Interior.ColorIndex = 2
Sheet2.Cells(44, 8) = " "
Sheet2.Cells(44, 9).Interior.ColorIndex = 2
Sheet2.Cells(44, 9) = " "
End If
For i = 97 To 125
If Sheet2.Cells(16, 2) = Sheet5.Cells(i, 2) Then
Sheet2.Cells(16, 3) = Sheet5.Cells(i, 3)
End If
If Sheet2.Cells(16, 7) = Sheet5.Cells(i, 2) Then
Sheet2.Cells(16, 8) = Sheet5.Cells(i, 3)
End If
If Sheet2.Cells(17, 2) = Sheet5.Cells(i, 2) Then
If Sheet2.Cells(17, 2) <> "Multi-Ply" Then
Sheet2.Cells(17, 3) = Sheet5.Cells(i, 3)
Else
Sheet2.Cells(17, 3) = " "
End If
End If
Next i
With Application
.Interactive = True
.EnableEvents = True
.ScreenUpdating = True
.Calculation = xlCalculationAutomatic
End With
Em có đoạn code như bên dưới, nhưng có vẻ nó chạy hơi chậm do k dung mảng... Moi ng có thể giúp em làm thế nào để tang tốc độ chạy code đó đc k ạ?
Ví dụ dùng mảng cũng đc.
Em xin cảm ơn!
With Application
.Interactive = False
.EnableEvents = False
.ScreenUpdating = False
.Calculation = xlCalculationManual
End With
Dim i As Integer
Dim j As Integer
If Sheet2.Cells(18, 3) <> 0 Then
If Sheet2.Cells(18, 3) < Sheet2.Cells(6, 9) Then
MsgBox "The Plan data could not smaller than AP date.", vbInformation, "Warning......!"
Sheet2.Cells(18, 3).Interior.ColorIndex = 45
Else
Sheet2.Cells(18, 3).Interior.ColorIndex = 2
End If
End If
If Sheet2.Cells(10, 2) = "General Expenditure" And Sheet2.Cells(10, 4) = "Purchase" Then
If Sheet2.Cells(10, 6) = "Tangible Goods" Or Sheet2.Cells(10, 6) = "Intangible Goods" Then
If Sheet2.Cells(25, 8) <> 0 And Sheet2.Cells(25, 8) > 30000000 Then
MsgBox "Check Whether FA Or Not.", vbInformation, "Warning......!"
Sheet2.Cells(25, 8).Interior.ColorIndex = 45
Else
Sheet2.Cells(25, 8).Interior.ColorIndex = 2
End If
End If
End If
If Sheet2.Cells(32, 4) <> " " And Sheet2.Cells(32, 4) > 2300000 Then
MsgBox "Over Limited Amount.", vbInformation, "Warning...Entertainment Fee Only.!"
Sheet2.Cells(32, 4).Interior.ColorIndex = 45
Else
Sheet2.Cells(32, 4).Interior.ColorIndex = 2
End If
' check chu ky
If Sheet2.Cells(10, 2) = "General Expenditure" Or Sheet2.Cells(10, 2) = "Tools & equipments" Or Sheet2.Cells(10, 2) = "Others" Then
If IsEmpty(Sheets("Approval sheet Form").Range("H25")) = False Then ' Kiem tra dieu kien H25 co du lieu
If Sheet2.Cells(25, 8).Value < 10000000 Then
Sheet2.Cells(44, 7).Interior.ColorIndex = 48
Sheet2.Cells(44, 7) = "Not Applicable"
Sheet2.Cells(44, 8).Interior.ColorIndex = 48
Sheet2.Cells(44, 8) = "Not Applicable"
Sheet2.Cells(44, 9).Interior.ColorIndex = 48
Sheet2.Cells(44, 9) = "Not Applicable"
ElseIf Sheet2.Cells(25, 8).Value > 10000000 And Sheet2.Cells(25, 8).Value < 250000000 Then
Sheet2.Cells(44, 7).Interior.ColorIndex = 48
Sheet2.Cells(44, 7) = "Not Applicable"
Sheet2.Cells(44, 8).Interior.ColorIndex = 2
Sheet2.Cells(44, 8) = " "
Sheet2.Cells(44, 9).Interior.ColorIndex = 2
Sheet2.Cells(44, 9) = " "
Else
Sheet2.Cells(44, 7).Interior.ColorIndex = 2
Sheet2.Cells(44, 7) = " "
Sheet2.Cells(44, 8).Interior.ColorIndex = 2
Sheet2.Cells(44, 8) = " "
Sheet2.Cells(44, 9).Interior.ColorIndex = 2
Sheet2.Cells(44, 9) = " "
End If
End If
Else
Sheet2.Cells(44, 7).Interior.ColorIndex = 2
Sheet2.Cells(44, 7) = " "
Sheet2.Cells(44, 8).Interior.ColorIndex = 2
Sheet2.Cells(44, 8) = " "
Sheet2.Cells(44, 9).Interior.ColorIndex = 2
Sheet2.Cells(44, 9) = " "
End If
For i = 97 To 125
If Sheet2.Cells(16, 2) = Sheet5.Cells(i, 2) Then
Sheet2.Cells(16, 3) = Sheet5.Cells(i, 3)
End If
If Sheet2.Cells(16, 7) = Sheet5.Cells(i, 2) Then
Sheet2.Cells(16, 8) = Sheet5.Cells(i, 3)
End If
If Sheet2.Cells(17, 2) = Sheet5.Cells(i, 2) Then
If Sheet2.Cells(17, 2) <> "Multi-Ply" Then
Sheet2.Cells(17, 3) = Sheet5.Cells(i, 3)
Else
Sheet2.Cells(17, 3) = " "
End If
End If
Next i
With Application
.Interactive = True
.EnableEvents = True
.ScreenUpdating = True
.Calculation = xlCalculationAutomatic
End With