Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Sub GopSheet_XoaTrung()
Dim x As Integer
Dim lr as long
Dim ws As Worksheet
On Error GoTo ErrHandler
Application.ScreenUpdating = False
'Gộp sheet
x = 1
For Each ws In ThisWorkbook.Sheets
If ws.Name <> "Tong Hop" Then
If x = 1 Then
ws.UsedRange.Copy Sheets("Tong Hop").Range("A1")
Else
lr = Sheets("Tong Hop").UsedRange.Rows.Count
ws.UsedRange.Offset(1).Copy Sheets("Tong Hop").Range("A" & lr + 1)
End If
x = x + 1
End If
Next ws
'Xóa trùng
lr = Sheets("Tong Hop").UsedRange.Rows.Count
Sheets("Tong hop").Range("A1:C" & lr).RemoveDuplicates Columns:=Array(1, 2, 3), Header:=xlYes
ErrHandler:
Debug.Print Err.Description
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.