Code của em kiểm tra mãi mà không phát hiện được chỗ sai, mong các pac giúp em
PHP:
Sub Loc()
Dim Arr(), DL(), KQ(), Dongcuoi As Long, i As Long, j As Long, m As Long
On Error GoTo NextStep
i = Sheets("Loc").Index
NextStep:
If i = 0 Then Sheets.Add.Name = "Loc"
Sheets("Loc").Move Before:=Sheets(1)
With Sheets("THop") ''Có the dung: With Sheet15
.[1:4].Copy Sheets("Loc").[A1]
Dongcuoi = .[A65000].End(xlUp).Row
DL = .Range("A5:J" & Dongcuoi).Value
End With
ReDim KQ(1 To UBound(DL, 1), 1 To UBound(DL, 2))
Arr = Array(211, 212, 213, 275, 252, 371, 519161, 519166, 519115, 519111, 519118, 519941, 519945, 519911, 519131, 41, 42, 4212, 4214, 4211, 702131, 702111, 702181, 702171, 494141)
Set Dic = CreateObject("Scripting.Dictionary")
For i = 0 To UBound(Arr, 1)
Tmp = Arr(i)
If Not Dic.Exists(Tmp) Then Dic.Add Tmp, ""
Next
For j = 1 To UBound(DL, 1)
If Dic.Exists(DL(j, 2)) Then
m = m + 1
For i = 1 To 10
KQ(m, i) = DL(j, i)
Next
End If
Next
With Sheets("Loc")
.Range("A5:J1000").ClearContents
.[A5].Resize(m, 10).Value = KQ
.UsedRange.Font.Name = ".VnTime"
Columns("K:K").ColumnWidth = 20
.Range("A1:J4").Font.Name = ".VnTimeH"
.UsedRange.Font.Size = 12
.UsedRange.EntireColumn.AutoFit
Columns("A:A").ColumnWidth = 35
.UsedRange.EntireRow.AutoFit
.UsedRange.NumberFormat = "#,##0"
End With
End Sub
File đính kèm
Lần chỉnh sửa cuối: