I need to use the SUMIF function dynamically in VBA. For the range, I have tried to build the range: "$C$2:$C$" & lastRow, but it does not work. I then created the variable: MyRange = $C$2:$C$ & lastRow and then I place MyRange in the SUMIF formula. Nothing works! An example of code:
lRow = Cells(Rows.Count, 3).End(xlUp).Row
myAddress = "$C$2:$C$" & lRow
MsgBox TypeName(myAddress)
Range("I:I").ClearContents
Range("I1").Value = Month(dtDate1)
Range("I2").Select
ActiveCell.Formula = "=sumif(myaddress,h2,$e$2)"
Solved by T. D. in 25 mins