Is it what you need ...?
Option Explicit
Sub Treat()
Dim InRg As Range, OutRg As Range
Dim ObjDic As Object
Set ObjDic = CreateObject("Scripting.Dictionary")
Dim InWS As Worksheet, OutWS As Worksheet
Dim LR As Integer, LC As Integer, I As Integer
Dim F
Set InWS = Sheets("Database")
Set OutWS = Sheets("NewData")
Set OutRg = Sheets("NewData").UsedRange
Set InRg = Sheets("Database").UsedRange
With InWS
LR = .Cells(Rows.Count, 1).End(xlUp).Row
LC = .Cells(1, Columns.Count).End(xlToLeft).Column
For I = 2 To LR
ObjDic.Item(.Cells(I, 1).Value) = .Cells(I, LC).Value
Next
End With
With OutWS
LR = .Cells(Rows.Count, 1).End(xlUp).Row
LC = .UsedRange.Columns.Count
For I = 3 To LR
If (ObjDic.exists(.Cells(I, 1).Value)) Then
.Cells(I, LC + 1).Value = ObjDic.Item(.Cells(I, 1).Value)
ObjDic.Remove (.Cells(I, 1).Value)
End If
Next
For Each F In ObjDic.keys
LR = LR + 1
.Cells(7, 1) = F
.Cells(7, LC) = ObjDic.Item(F)
Next
End With
End Sub
Bookmarks