Professional Documents
Culture Documents
新規 Microsoft Word 文書
新規 Microsoft Word 文書
新規 Microsoft Word 文書
'T のデータを上から順番に繰り返す
For i = 2 To Lastrow
検索値 = wsT.Cells(i, 1)
個数 = WorksheetFunction.CountIfs(wsR.Range("A:A"), 検索値)
個数 2 = WorksheetFunction.CountIfs(ws 結果.Range("A:A"), 検索値)
'関数の結果が 0 より大きいならば
If 個数 = 0 And 個数 2 = 0 Then
'転記先行を取得
'差分を結果シートに転記
ws 結果.Cells(Maxrow, 1) = wsT.Cells(i, 1)
'DB シートの最終行を取得
For j = 2 To maxrow2
'もし、合致したら
ws 結果.Cells(Maxrow, 3) = wsDB.Cells(j, 3)
ws 結果.Cells(Maxrow, 2) = wsDB.Cells(j, 2)
End If
End If
Next
For j = 2 To maxrow2
'もし、合致したら
ws 結果.Cells(Maxrow, 3) = wsDB.Cells(j, 3)
ws 結果.Cells(Maxrow, 2) = wsDB.Cells(j, 2)
End If
End If
Next
For j = 2 To maxrow2
'もし、合致したら
ws 結果.Cells(Maxrow, 3) = wsDB.Cells(j, 3)
‘列を追加するところ↓
ws 結果.Cells(Maxrow, 2) = wsDB.Cells(j, 2)
End If
End If
Next
For j = 2 To maxrow2
ws 結果.Cells(Maxrow, 2) = wsDB.Cells(j, 2)
End If
Next
End If
Next
End Sub