I would like to generate a formula in my code, say for example:
Range("L2:L17).Formula="=SUMIF($A$2:$A$17,A2,G2:G17)"
Except, I would like L, G, and A to be variables that are decided by some other factors earlier in the macro. Similarly, I would also like 2 and 17 to be replaced by two variables, whose specific values are determined earlier in the code.
So something like
Range("var1 j: var1 k).Formula="=SUMIF($ var2 $ j : $ var2 $ k, var2 j, var3 j : var3 k)"
I guess I could convert these variables to string and just do a string concatenate but I am not able to do it just yet. Everything I try gives errors.
Range(foldtot_add & "2:"& foldtot_add & FinalRow).Formula="=SUMIF("$"&FolderId_add & "$2:" & "$"& FolderId_add & FinalRow, FolderId_add &" 2", daycountcol2 & "2 :" & daycountcol2 & FinalRow)"
Where foldtot_add, FolderId_add, and daycountcol2 are names of my columns and FinalRow is the name of a row.