I have tried to debug my code, I came up with this code and has a lil error than before. Can someone check where I have done wrong? It seems that i am able to transfer all the data from the copydata tab to the finaldata tab but in a different cell, attached is my file.
Sheet1.Select Range("F" & cnt).Value = RowCount
Sheet2.Select
rn = Sheet2.UsedRange.Rows(Sheet2.UsedRange.Rows.Count).Row
For i = 1 To Sheet2.UsedRange.Columns.Count Step 1
Set x = Sheet3.Rows(1).Find(Sheet2.Cells(1, i).Value, LookIn:=xlValues, lookat:=xlWhole)
If Not x Is Nothing Then
Sheet3.Select
Cells(2, x.Column).Select
Range(Selection, Selection.End(xlDown)).Copy
Sheet2.Select
Cells(rn + 1, i).Select
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
End If
Set x = Nothing
Next i
Sheet2.Select
Range("A" & RowCount + 1).Select
Range(Selection, Selection.End(xlUp).Offset(1)).Value = Sheet1.Range("D" & cnt).Value
Sheet1.Select