tags:

views:

131

answers:

1

Hello,

I'm trying to write in Visual Basic (in Excel 2007) the following sumifs code (the I column and the F column are contained in a Table):

    Range("AA5").Value = "=SUMIFS(I5:I420,K5:K420," & "B1" & ",F5:F420," & "6009" & ")"

"B1" and "6009" is what I want it to look for and the I column is the column I want added.

Can you please tell me where I am going wrong.

Thank you, AW

+1  A: 

Try

Range("AA5").Formula = ...

Also, I'm not sure why you're concatenating your strings instead of this:

Range("AA5").Formula = "=SUMIFS(I5:I420,K5:K420,B1,F5:F420,6009)"

unless B1 and 6009 are dynamic values that are being replaced.