currently I have a relatively complex workbook formula, which I would like to translate to a vba formula.
Currently, I wrote the following but I want it to basically evaluate the function during code execution and insert the value into the required cell.
I imagine this is some combination of worksheetfunction
but I am unsure of how to translate this
Code (doesnt work)
MWS.Cells(LastMWSR + 1, ClastMWSC).Value = WorksheetFunction.SUMIFS(mws.range(N:N),mws.Range(B:B),worksheetfunction.INDEX(mws.range(B:B),worksheetfunction.MAX(worksheetfunction.INDEX((mws.range(C:C)=MWS.Cells(LastMWSR + 1, ClastMWSC - 1))*worksheetfunction.ROW(mws.range(C:C)),0))),mws.range(C:C),MWS.Cells(LastMWSR + 1, ClastMWSC - 1))
Excel Formula
=SUMIFS($N:$N,$B:$B,INDEX($B:$B,MAX(INDEX(($C:$C=$AM41)*ROW($C:$C),0))),$C:$C,$AM41)
MWS is a worksheet
LastMWSR is the last row in the Worksheet
CLASTMWSC is the last column in the worksheet
Appreciate your thoughts
EDIT: with another attempt at the formula