Private Sub CommandButton4_Click()
Dim Formule As String
Dim name As String
Dim mese As String
name = ComboBox1.Value
mese = TextBox2.Value
Formule = '=SUMPRODUCT((prim!$E$2:$E$799=''' & name & ''')*(MONTH(prim!$B$2:$B$799)=' & mese & ')*prim!$D$2:$D$799)'
With Worksheets('Stat')
.Range('I1').Formula = Formule
Calculate
textbox1.Value = .Range('I1')
End With
End Sub