desculpe, madei sem testar, acabel cometendo o mesmo erro seu apesar de ter ficado mais rapido
Sub novoano()
Dim Li As Long, Lf As Long, Ci As Long, Cf As Long, L2 As Long, Coluno(), ColunD()
Limpar
Ci = 1
Cf = Plan12.Cells(1, Columns.Count).End(xlToLeft).Column
With Plan13
With .Range("A1", .Cells(1, Cf))
.Interior.Color = RGB(192, 192, 192)
.Font.Color = RGB(0, 0, 0)
.Font.Bold = True
.HorizontalAlignment = xlCenter
End With
Lf = Plan12.Cells(Rows.Count, 1).End(xlUp).Row + 1
Coluno = Plan12.Range("A2", Plan12.Cells(Lf, Cf)).Value2
ct = UBound(Coluno, 2)
ReDim ColunD(1 To 1, 1 To ct)
L2 = 1
For l = 1 To UBound(Coluno, 1)
If Year(Coluno(l, 1)) = ColunD(1, 1) Then
For c = 2 To ct
ColunD(1, c) = ColunD(1, c) + Coluno(l, c)
Next
Else
.Range(.Cells(L2, 1), .Cells(L2, Cf)).Value2 = ColunD
L2 = L2 + 1
For c = 2 To ct
ColunD(1, c) = 0
Next
ColunD(1, 1) = Year(Coluno(l, 1))
For c = 2 To ct
ColunD(1, c) = ColunD(1, c) + Coluno(l, c)
Next
End If
Next
.Range("A1", .Cells(1, Cf)).Value2 = Plan12.Range("A1", Plan12.Cells(1, Cf)).Value2
End With
End Sub
Postado : 06/03/2016 9:51 pm