Hi
Again, have a blank sheet called Sheet2, and run this on the raw data. It will build the relevant headings, and put the data in the right place (famous last words!)
Sub aaa()
Dim OutSH As Worksheet
Set OutSH = Sheets("Sheet2")
OutSH.Range("A1").Value = "MATERIAL__MAT_ID"
For i = 2 To Cells(Rows.Count, 1).End(xlUp).Row
Set findit = OutSH.Range("A:A").Find(what:=Cells(i, 1))
Set findcol = OutSH.Rows("1:1").Find(what:=Cells(i, 2), lookat:=xlWhole)
If findit Is Nothing Then
OutSH.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Value = Cells(i, 1)
Set findit = OutSH.Range("A:A").Find(what:=Cells(i, 1))
End If
If findcol Is Nothing Then
OutSH.Cells(1, Columns.Count).End(xlToLeft).Offset(0, 1).Value = Cells(i, 2)
Set findcol = OutSH.Rows("1:1").Find(what:=Cells(i, 2), lookat:=xlWhole)
End If
OutSH.Cells(findit.Row, findcol.Column).Value = Cells(i, 2).Value
Next i
End Sub
rylo
Bookmarks