or
Code:
Sub M_snb()
sp = Sheet3.Cells(1).CurrentRegion.Rows(1)
ReDim sq(0, UBound(sp, 2))
sn = [if(sheet1!A1:A1000="","",if(Column(A1:C1000)=1,A1:A1000,if($B1:$B1000="",offset(A1:C1000,,2),$A1:$C1000)))]
With CreateObject("scripting.dictionary")
For j = 2 To UBound(sn)
st = .Item(sn(j, 1))
If VarType(st) = 0 Then st = sq
st(0, 0) = sn(j, 1)
If Not IsError(Application.Match(sn(j, 2), sp, 0)) Then st(0, Application.Match(sn(j, 2), sp, 0) - 1) = sn(j, 3)
.Item(sn(j, 1)) = st
Next
Sheet3.Cells(2, 1).Resize(.Count, UBound(sp, 2) + 1) = Application.Index(.items, 0, 0)
End With
End Sub
Bookmarks