- Tham gia
- 5/6/08
- Bài viết
- 30,703
- Được thích
- 53,963
Thừa thắng xong lên: Lọc 1 phát toàn bộ các sheet và đặt kết quả vào cột F của sheet cuối cùng (đồng thời sort luôn kết quả)
Code cũng ngắn tí tẹo
PHP:
Option Explicit
Sub Loc()
Dim i, Er As Long
Application.ScreenUpdating = False
With Range("E1")
.Value = "TEN"
.HorizontalAlignment = xlCenter
.Font.Bold = True
End With
For i = 1 To ThisWorkbook.Worksheets.Count
Er = [E65000].End(xlUp).Row + 1
Sheets(i).[A1].CurrentRegion.Copy Destination:=Range("E" & Er)
Next
Range("E1:E" & Er - 1).AdvancedFilter Action:=1, Unique:=1
Range("E1:E" & Er - 1).SpecialCells(xlCellTypeVisible).Copy Destination:=[F1]
ActiveSheet.ShowAllData
Columns("E:E").ClearContents
[F1].CurrentRegion.Sort Key1:=Range("F2"), Order1:=1, Header:=1
Application.ScreenUpdating = True
End Sub
File đính kèm
Lần chỉnh sửa cuối: