• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Sumifs in VBA

Dear

I want to build the sumifs function in VBA

I've allready these commands in a specific worksheet

Code:
Dim c1 As String, c2 As String, c3 As String, c4 As String

c1="Company1"
c3="Company2"
c3="Company3"

Range("C9").Select - ' where the formula should be placed

ActiveCell.FormulaR1C1 = _

  "=SUMIFS(Table1[em EUR],Table1[Unidade Negócio],c1)"

The thing is that, placed like this, the formula should be returning:

=SUMIFS(Table1[em EUR],Table1[Unidade Negócio],"Company1"), but insted it is returning:

=SUMIFS(Table1[em EUR],Table1[Unidade Negócio],$A:$A)

What's wrong in here?

Thank you all

Best Regards
 
Hi ,

Use this :

ActiveCell.Formula = "=SUMIFS(Table1[em EUR],Table1[Unidade Negócio]," & """" & c1 & """" & ")"

Narayan
 
Back
Top