solution with code
Sub test()
Dim ws1 As Worksheet, ws2 As Worksheet, lr1 As Long, lr2 As Long, x As Long, i As Long
Set ws1 = Sheets("% Split per cost centre")
Set ws2 = Sheets("Raw Data")
lr1 = ws1.Range("A" & Rows.Count).End(xlUp).Row
lr2 = ws2.Range("A" & Rows.Count).End(xlUp).Row
For x = 2 To lr2
If ws2.Range("G" & x) = "" Then
For i = 2 To lr1
If ws2.Range("A" & x) & ws2.Range("B" & x) & ws2.Range("C" & x) = _
ws1.Range("A" & i) & ws1.Range("B" & i) & ws1.Range("C" & i) Then
mycol = Application.Match("Cost Center" & Chr(10) & ws1.Range("F" & i), Range("1:1"), 0)
If IsError(mycol) Then
mycol = ws2.Cells(1, Columns.Count).End(xlToLeft).Offset(, 1).Column
ws2.Cells(1, mycol) = "Cost Center" & Chr(10) & ws1.Range("F" & i)
ws2.Cells(1, mycol).Font.Size = 9
ws2.Cells(1, mycol).HorizontalAlignment = xlCenter
End If
ws2.Cells(x, mycol) = ws2.Range("F" & x) * ws1.Range("G" & i)
End If
Next
End If
Next
End Sub
Kind regards
Leo
Bookmarks