Created
November 7, 2019 16:53
-
-
Save syxolk/fa6504e706dac054cdbad88a9ebbce10 to your computer and use it in GitHub Desktop.
VBA Set Intersections
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
Option Explicit | |
Sub IntersectionMacro() | |
Dim set1 As New Scripting.Dictionary | |
Dim set2 As New Scripting.Dictionary | |
Dim result As New Scripting.Dictionary | |
set1.Add "M AB 123", "" | |
set1.Add "M CD 456", "" | |
set1.Add "M EF 789", "" | |
set1.Add "B AA 22", "" | |
set2.Add "M CD 456", "" | |
set2.Add "J GH 000", "" | |
set2.Add "M EF 789", "" | |
set2.Add "B AA 22", "" | |
set2.Add "EF ZZ 111", "" | |
Intersect set1, set2, result | |
Dim Key As Variant | |
Dim i As Integer | |
i = 1 | |
For Each Key In result.Keys | |
Cells(i, 1) = Key | |
i = i + 1 | |
Next Key | |
End Sub | |
Sub Intersect(set1 As Scripting.Dictionary, set2 As Scripting.Dictionary, ByRef result As Scripting.Dictionary) | |
Dim Key As Variant | |
For Each Key In set1.Keys | |
If set2.Exists(Key) Then | |
result.Add Key, "" | |
End If | |
Next Key | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Unter Extras -> Verweise ...
... muss die "Microsoft Scripting Runtime" aktiviert werden