我正在尝试在代码中使用Sumifs函数,但是其中一个条件(日期-函数中的最后一个条件)不起作用。有人有任何想法吗?
然后我借此机会提出另一个问题:我的行范围为2000行,我的代码很慢。有人有什么想法可以帮助我吗?
Sub ATUALIZAR()
Application.ScreenUpdating = False
'Planilha Ativa
Worksheets("TabContratos").Activate
'Count the number of rows
i = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row
'The date here is 05/31/2019
j = Worksheets("VPL Mês").Cells(2, 4).Value
k = 2
Do While Not IsEmpty(Cells(k, 1))
'Suply Date
Cells(k, 58).Value = DateSerial(Cells(k, 8).Value, Cells(k, 9).Value + 1, "1") - 1
'Class
If Cells(k, 7).Value < j Then
Cells(k, 59).Value = "-"
Else
If Cells(k, 7).Value <= WorksheetFunction.EoMonth(j, 12) Then
Cells(k, 59).Value = "Circulante"
Else
Cells(k, 59).Value = "Não Circulante"
End If
End If
'Sumifs
Cells(k, 60).Value = WorksheetFunction.SumIfs(Range(Cells(2, 43), Cells(i, 43)), Range(Cells(2, 1), Cells(i, 1)), Cells(k, 1), Range(Cells(2, 58), Cells(i, 58)), ">" & j)
k = k + 1
Loop
Application.ScreenUpdating = True
End Sub