According to your last updated attachment a VBA demonstration for starters :
PHP Code:
Sub Demo1()
Dim S&, W(2 To 4), R&, N&, C%, V()
Sheets(5).UsedRange.Offset(1).Clear
With New Collection
For S = 2 To 4
W(S) = Sheets(S).[A1].CurrentRegion
For R = 2 To UBound(W(S))
For N = 1 To .Count
C = StrComp(.Item(N), W(S)(R, 2), 1)
If C >= 0 Then
If C Then .Add W(S)(R, 2), , N
Exit For
End If
Next
If N > .Count Then .Add W(S)(R, 2)
Next R, S
For R = 1 To .Count: .Add R, .Item(R), R: .Remove R + 1: Next
ReDim V(1 To .Count, 1 To 11)
For S = 2 To 3
For N = 2 To UBound(W(S))
R = .Item(W(S)(N, 2))
If IsEmpty(V(R, 1)) Then V(R, 1) = R: For C = 2 To 5: V(R, C) = W(S)(N, C): Next
V(R, 6) = V(R, 6) + W(S)(N, 6)
V(R, 10) = V(R, 10) + W(S)(N, 8 - (S = 2))
If S = 2 Then V(R, 11) = V(R, 11) + W(S)(N, 10)
Next N, S
For N = 2 To UBound(W(4))
R = .Item(W(4)(N, 2))
V(R, 7) = V(R, 7) + W(4)(N, 6)
V(R, 11) = V(R, 11) + W(4)(N, 8)
Next
For R = 1 To .Count
For C = 0 To 1
If V(R, 6 + C) Then V(R, 8 + C) = V(R, 10 + C) / V(R, 6 + C)
Next C, R
End With
With Sheets(5).Range("A1:K" & R).Columns
.Borders.Weight = 2
.Font.Name = .Cells(1).Font.Name
.Item("A:G").NumberFormat = "_W# ###_W;;; @ "
.Item("H:K").NumberFormat = "_W# ##0.00_W;;; @ "
With .Rows("2:" & R): .Font.Size = 12: .Value = V: End With
.AutoFit
End With
End Sub
► Do you like it ? ► ► So thanks to click on bottom left star icon « ★ Add Reputation » ! ◄ ◄
Bookmarks