简体   繁体   中英

Using SUMIFS in Excel-vba to check multiple conditions

I have just started using SUMIFS in vba and I need to check multiple conditions. It should check if something matches either of these AA, AT, AB, AC, AN, AR, AD

I have this code so far which works for only one condition.

WorksheetFunction.SumIfs(TotQty, Style, CellVal, TotQty, ">0", Location, "AA")

Any idea how to adjust it to search for all other options?

Well you can do something like:

MsgBox [Sum(SumIfs(TotQty, Style, CellVal, TotQty, ">0", Location, {"AA","AT","AB","AC","AN","AR","AD"}))]

or

MsgBox Evaluate("=SUM(SumIfs(TotQty, Style, CellVal, TotQty, "">0"", Location, {""AA"",""AT"",""AB"",""AC"",""AN"",""AR"",""AD""}))")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM