Is there a faster way for the VBA macro to execute my formula?

79 Views Asked by At

I created a macro and I'm using the following way to calculate the maximum value:

UltimaLinha = Workbooks(modelo).Sheets(NomeAba).Cells(Workbooks(modelo).Sheets(NomeAba).Rows.Count, "A").End(xlUp).Row

Dim rng As Range
Set rng = ws.Range("V5:V" & UltimaLinha)

rng.Formula = "=IFERROR(MAXIFS(matriz_de_custos!$P$2:$P$" & UltimaLinha_mc & ",matriz_de_custos!$L$2:$L$" & UltimaLinha_mc & ",RC[-18],matriz_de_custos!$U$2:$U$" & UltimaLinha_mc & ",RC[-17],matriz_de_custos!$D$2:$D$" & UltimaLinha_mc & ",RC[-12]),0)"

rng.Value = rng.Value

But as I need to do this operation several times, the macro is taking a long time to execute... Is there a better or faster way to execute this process?

I just tried using batch calculation, which was the code I posted.

0

There are 0 best solutions below