Something like below should help you.thanks if any macro is there
Public Sub TransposeData()
Dim lngOutRow As Long: lngOutRow = 6 '\\ Change to suit
Dim lngOutCol As Long: lngOutCol = 9 '\\ Change to suit
Dim i As Long
Dim objDict As Object: Set objDict = CreateObject("Scripting.Dictionary")
objDict.CompareMode = vbTextCompare
'\\ Load in Dictionary
For i = 3 To Range("A" & Rows.Count).End(xlUp).Row
If objDict.Exists(Range("A" & i).Value & "|" & Range("B" & i).Value) Then
objDict.Item(Range("A" & i).Value & "|" & Range("B" & i).Value) = _
objDict.Item(Range("A" & i).Value & "|" & Range("B" & i).Value) & "|" & Range("C" & i).Value & "|" & Range("D" & i).Value
Else
objDict.Add Range("A" & i).Value & "|" & Range("B" & i).Value, Range("C" & i).Value & "|" & Range("D" & i).Value
End If
Next i
'\\ Get Dictionary output in cells
Dim k, s
For Each k In objDict.Keys
s = Split(k & "|" & objDict.Item(k), "|")
Cells(lngOutRow, lngOutCol).Resize(1, UBound(s) + 1) = s
lngOutRow = lngOutRow + 1
Next k
'\\ Release object
Set objDict = Nothing
End Sub
You have changed requirement which you should've stated in the first post itself. Is this your final layout?Hi
Thanks for the macro .
If i want to add extra column where to change the code
I added two columns but the data is not filling properly attached the file for the reference.
And also if i want to copy the file in the next sheet what is the macro code
Regards
shahul
Based on your inputs I have revised code. It is final offering from my side. You will have to do further amendments if requirements change again!Hi
Ataching the updated file can u help in macro for the output data
Public Sub TransposeData()
Dim wksOutSht As Worksheet: Set wksOutSht = ThisWorkbook.Sheets(2) '\\ Change to suit
Dim lngOutRow As Long: lngOutRow = 2 '\\ Change to suit
Dim lngOutCol As Long: lngOutCol = 1 '\\ Change to suit
Dim i As Long
Dim objDict As Object: Set objDict = CreateObject("Scripting.Dictionary")
objDict.CompareMode = vbTextCompare
'\\Empty destination sheet
wksOutSht.UsedRange.ClearContents
'\\ Load in Dictionary
For i = 3 To Range("A" & Rows.Count).End(xlUp).Row
If objDict.Exists(Range("A" & i).Value & "|" & Range("B" & i).Value & "|" & Range("C" & i).Value) Then
objDict.Item(Range("A" & i).Value & "|" & Range("B" & i).Value & "|" & Range("C" & i).Value) = _
objDict.Item(Range("A" & i).Value & "|" & Range("B" & i).Value & "|" & Range("C" & i).Value) & "|" _
& Range("D" & i).Value & "|" & Range("E" & i).Value & "|" & Range("F" & i).Value & "|" & Range("G" & i).Value _
& "|" & Range("H" & i).Value & "|" & Range("I" & i).Value
Else
objDict.Add Range("A" & i).Value & "|" & Range("B" & i).Value & "|" & Range("C" & i).Value, _
Range("D" & i).Value & "|" & Range("E" & i).Value & "|" & Range("F" & i).Value & "|" & Range("G" & i).Value _
& "|" & Range("H" & i).Value & "|" & Range("I" & i).Value
End If
Next i
'\\ Get Dictionary output in cells
Dim k, s
For Each k In objDict.Keys
s = Split(k & "|" & objDict.Item(k), "|")
wksOutSht.Cells(lngOutRow, lngOutCol).Resize(1, UBound(s) + 1) = s
lngOutRow = lngOutRow + 1
Next k
'\\ Release object
Set objDict = Nothing
End Sub