Trần Văn Bình
GTVT
- Tham gia
- 30/7/06
- Bài viết
- 409
- Được thích
- 372
- Nghề nghiệp
- GTVT
Hiện mình có ghi Reccord nhưng chạy chậm nhờ các bạn sữa lại đoạn code sau:
Sub Countif_Col_AC()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Application.Calculation = xlCalculationManual
Application.AskToUpdateLinks = False
Dim Lr As Long
Dim i As Integer
With Sheet1
Lr = Sheet1.Range("I" & Rows.Count).End(xlUp).Row
'Sheet1.Range("AC:AC" & Lr).ClearContents
For i = 3 To Lr
Range("AC" & i).Select
ActiveCell.FormulaR1C1 = _
"=IF(RC[-20]<>"""",COUNTIF(RC[-12]:RC[-1],""x""),"""")"
Range("AC" & i).Select
' Selection.AutoFill Destination:=Range("AC3:AC" & i)
'Range("AC3:AC" & i).Select
Next i
End With
Application.ScreenUpdating = True
Application.DisplayAlerts = True
Application.Calculation = xlCalculationAutomatic
Application.AskToUpdateLinks = True
End Sub
Sub Countif_Col_AC()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Application.Calculation = xlCalculationManual
Application.AskToUpdateLinks = False
Dim Lr As Long
Dim i As Integer
With Sheet1
Lr = Sheet1.Range("I" & Rows.Count).End(xlUp).Row
'Sheet1.Range("AC:AC" & Lr).ClearContents
For i = 3 To Lr
Range("AC" & i).Select
ActiveCell.FormulaR1C1 = _
"=IF(RC[-20]<>"""",COUNTIF(RC[-12]:RC[-1],""x""),"""")"
Range("AC" & i).Select
' Selection.AutoFill Destination:=Range("AC3:AC" & i)
'Range("AC3:AC" & i).Select
Next i
End With
Application.ScreenUpdating = True
Application.DisplayAlerts = True
Application.Calculation = xlCalculationAutomatic
Application.AskToUpdateLinks = True
End Sub