To reference a worksheet you can add a variable and set it to that worksheet

sumifmacro Macro'
'Dim ws   As Worksheet
Set ws = workshets("whatever name")  or use Set ws=Sheet1   
ws.Range("E4").ActiveCell.FormulaR1C1 = _
        "=SUMIF('ancma 4-7-2019'!R3C2:R173C2,april!RC9,'ancma 4-7-2019'!R3C5:R173C5)"
End Sub
DO NOT SELECT just refer to a range