|
こんにちは
こんな感じでいかがでしょうか。^d^
Sub test()
Dim Dic As Object
Dim myData As Variant
Dim i As Long
Dim S As String
Dim rngDest As Range
Dim myPath As String
Dim N As Integer
Dim V As Variant
'辞書機能を使う
Set Dic = CreateObject("Scripting.Dictionary")
'元データと初期書き込み先
With Workbooks("B.xls").Worksheets("Sheet1")
myData = .Range("A1", .Range("C65536").End(xlUp)).Value
Set rngDest = .Cells(UBound(myData) + 1, 1)
End With
'辞書に登録
For i = 1 To UBound(myData)
S = myData(i, 1)
S = S & "," & myData(i, 2)
S = S & "," & myData(i, 3)
Dic.Item(S) = Empty
Next
'テキストファイル
myPath = ThisWorkbook.Path & "\a.txt"
N = FreeFile
'読み込み
Open myPath For Input As #N
Do Until EOF(N)
Line Input #N, S
V = Split(S, ",")
'同じ行が無ければ
If Not Dic.Exists(S) Then
rngDest.Resize(, 3).Value = V
Set rngDest = rngDest.Offset(1)
Dic.Item(S) = Empty
End If
Loop
Close #N
Set rngDest = Nothing
Set Dic = Nothing
End Sub
|
|