Created
April 26, 2018 01:24
-
-
Save TGDUY/5079325ad7440574ef07da1796d89034 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Function SoSanh(ListA As Range, ListB As Range, Cr As Byte) As Variant | |
| Dim Dic As Object, TmpA As Variant, TmpB As Variant, I As Long, J As Long, Tmp As Variant | |
| Set Dic = CreateObject("Scripting.Dictionary") | |
| TmpA = ListA.Value2: TmpB = ListB.Value2: ReDim Tmp(0) | |
| J = -1 | |
| For I = LBound(TmpA, 1) To UBound(TmpA, 1) | |
| If Not Dic.exists(CStr(TmpA(I, 1))) Then Dic.Add CStr(TmpA(I, 1)), CStr(TmpA(I, 1)) | |
| Next | |
| For I = LBound(TmpB, 1) To UBound(TmpB, 1) | |
| If Dic.exists(CStr(TmpB(I, 1))) Then | |
| Dic.Remove CStr(TmpB(I, 1)) | |
| J = J + 1 | |
| ReDim Preserve Tmp(J) | |
| Tmp(J) = CStr(TmpB(I, 1)) | |
| End If | |
| Next | |
| If Cr = 1 Then | |
| SoSanh = Application.WorksheetFunction.Transpose(Dic.keys) | |
| ElseIf Cr = 2 Then | |
| SoSanh = Application.WorksheetFunction.Transpose(Tmp) | |
| End If | |
| End Function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment