Forum Discussion

hrh_dash's avatar
hrh_dash
Iron Contributor
Sep 10, 2022
Solved

Macro to sumifs a range of values based on dates

I would like to translate the following excel formula to a macro for the sumifs of values based on dates.   Currently I am getting an error msg pop up "Run time error 13 Type mismatch"   Excel fo...
  • HansVogelaar's avatar
    Sep 10, 2022

    hrh_dash 

    You have to concatenate with the variable prevdate, and double the quotes in the string.

            .Formula = "=SUMIFS(B:B,A:A,"">=""&DATE(YEAR(" & prevdate & "),MONTH(" & prevdate & "),1),A:A,""<=""&EOMONTH(" & prevdate & ",0))"
    

     

Resources