+ Reply to Thread
Results 1 to 4 of 4

Trying to sumifs with multiple criteria in the same column

Hybrid View

  1. #1
    Registered User
    Join Date
    07-14-2013
    Location
    Grand Rapids, Michigan
    MS-Off Ver
    Excel 2010
    Posts
    35

    Trying to sumifs with multiple criteria in the same column

    Alright, so here goes. I have a front end formula that I'm trying to turn into vba, but I can't seem to get it to work the same way, or at all for that matter.

    I have a sheet with a list of industries in column "A." Next to them, in column "B" are a list of values, we'll say $ amounts.

    So, the formula I created that seemed to work was:

    =sum(sumif(B:B,A:A,{"BusinessServices", "Healthcare"}))
    So, I simply tried replicating it in vba with:

    =application.sum(application.sumif(sheet1.range("B:B","A:A",{var1, var2})))
    where the 'vars' represent one of the above values . . . and it errors out because the curly brace isn't a recognized symbol in the excel vbe.

    Any assistance you can provide me in finding a workaround for this seemingly rather simple problem is greatly appreciated.

    Thank you in advance for considering helping.

    I would attach a workbook, but I only have excel 2003 at home and I'm using 10 at work . . . also sorry in advance

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: Trying to sumifs with multiple criteria in the same column

    The syntax for the worksheet formula would be...
    Formula: copy to clipboard
    =sum(sumif(A:A,{"BusinessServices", "Healthcare"},B:B))


    The VBA equivalent could be...
    x = Evaluate("SUM(SUMIF(A:A,{""" & var1 & """,""" & var2 & """},B:B))")
    Or...
    y = Application.Sum(Application.SumIf(Sheet1.Range("A:A"), Array(var1, var2), Sheet1.Range("B:B")))
    Or...
        Dim MyArray As Variant
        MyArray = Array("BusinessServices", "Healthcare")
        z = Application.Sum(Application.SumIf(Sheet1.Range("A:A"), MyArray, Sheet1.Range("B:B")))
    Last edited by AlphaFrog; 07-22-2016 at 08:38 PM.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Registered User
    Join Date
    07-14-2013
    Location
    Grand Rapids, Michigan
    MS-Off Ver
    Excel 2010
    Posts
    35

    Re: Trying to sumifs with multiple criteria in the same column

    Awesome, figured it would be an easy enough solution. Thank you, thank you, thank you!!!! Saved ME!!!

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: Trying to sumifs with multiple criteria in the same column

    You're welcome. Thanks for the feedback.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] SUMIFS Multiple Criteria Same Column
    By jsharrard in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 08-18-2017, 05:08 PM
  2. [SOLVED] SUMIFS with text wildcard and multiple criteria in the same column
    By rs1aj in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 04-18-2016, 11:59 AM
  3. [SOLVED] Sumifs to check multiple criteria in the same column
    By fcheng15 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 05-08-2015, 09:16 AM
  4. [SOLVED] SUMIFS w/ multiple criteria in a single column (using references to cells, not values)
    By akamenov88 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 02-15-2015, 06:16 PM
  5. sumifs with multiple criteria in one column.
    By apolloni in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 11-10-2014, 05:13 AM
  6. [SOLVED] SumIfs with multiple criteria (search column for cells w/ text containing)
    By jerrydiaz in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-22-2013, 01:06 PM
  7. Replies: 3
    Last Post: 11-21-2012, 04:57 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1