Option Explicit
Sub Combine()
Dim Dic As Object, I As Long, J As Long, Lr As Long, K As Long, Txt As String, sArr(), dArr()
Set Dic = CreateObject("Scripting.Dictionary")
With Sheets("Transaction")
Lr = .Columns("A:C").Find("*", searchorder:=xlByRows, searchdirection:=xlPrevious).Row
If Lr < 2 Then Exit Sub
sArr = .Range("A2:B" & Lr).Value
ReDim dArr(1 To UBound(sArr, 1), 1 To 1)
With Dic
For J = 1 To UBound(sArr, 2)
For I = 1 To UBound(sArr, 1)
Txt = Replace(sArr(I, J), " ", "")
If Not .exists(Txt) And Len(Txt) Then
K = K + 1
.Add Txt, K
dArr(K, 1) = Txt
End If
Next
Next
End With
.Range("D2" & .Rows.Count).ClearContents
.Range("D2").Resize(K) = dArr
End With
Set Dic = Nothing
End Sub
Sub copydata()
Dim wb As Workbook, wbmain As Workbook
Application.ScreenUpdating = False
Set wbmain = ThisWorkbook
Set wb = Workbooks.Open("C:\Users\ngocminh.phan\Desktop\cc.xlsx")
wb.Sheets("Transaction").Range("V2:X80000").Copy wbmain.Sheets("Transaction").Range("A2")
wb.Close False
End Sub
Sub Macro1()
'
' Macro1 Macro
'
'
Sheets("Transaction").Select
Range("A280000").Select
Application.CutCopyMode = False
Selection.ClearContents
Sheets("VBA").Select
Range("B1").Select
End Sub
Option Explicit
Sub Combine()
Dim Dic As Object, I As Long, J As Long, Lr As Long, K As Long, Txt As String, sArr(), dArr()
Set Dic = CreateObject("Scripting.Dictionary")
With Sheets("Transaction")
Lr = .Columns("A:C").Find("*", searchorder:=xlByRows, searchdirection:=xlPrevious).Row
If Lr < 2 Then Exit Sub
sArr = .Range("A2:B" & Lr).Value
ReDim dArr(1 To UBound(sArr, 1), 1 To 1)
With Dic
For J = 1 To UBound(sArr, 2)
For I = 1 To UBound(sArr, 1)
Txt = Replace(sArr(I, J), " ", "")
If Not .exists(Txt) And Len(Txt) Then
K = K + 1
.Add Txt, K
dArr(K, 1) = Txt
End If
Next
Next
End With
.Range("D2" & .Rows.Count).ClearContents
.Range("D2").Resize(K) = dArr
End With
Set Dic = Nothing
End Sub
Sub copydata()
Dim wb As Workbook, wbmain As Workbook
Application.ScreenUpdating = False
Set wbmain = ThisWorkbook
Set wb = Workbooks.Open("C:\Users\ngocminh.phan\Desktop\cc.xlsx")
wb.Sheets("Transaction").Range("V2:X80000").Copy wbmain.Sheets("Transaction").Range("A2")
wb.Close False
End Sub
Sub Macro1()
'
' Macro1 Macro
'
'
Sheets("Transaction").Select
Range("A280000").Select
Application.CutCopyMode = False
Selection.ClearContents
Sheets("VBA").Select
Range("B1").Select
End Sub
Bài của em lúc chiều là chép lại 100 / 100 nội dung của chủ thớt ở "thớt kia", hoàn toàn phù hợp (cung cấp thêm thông tin, nguồn gốc cho bài #1) mà vẫn bị xóa. Ca này khó hiểu.