WorksheetFunction.SumIfs

Yamezz

Active Member
Joined
Nov 22, 2006
Messages
336
Office Version
  1. 2019
What am I doing wrong with the syntax here:
VBA Code:
Qty = Application.worksheetfunction.SumIfs(OpenReport.ActiveSheet.range("D2", "D" & LastRow), _
        OpenReport.Activesheet.range("B2", "B" & LastRow), "True" _
        OpenReport.Activesheet.range("E2", "E" & LastRow), SKU _
        OpenReport.Activesheet.range("I2", "I" & LastRow), DUP)

My intention is to set the Qty variable to the sum of Column D where Column B contains the text "TRUE", Column E is the current SKU being examined and Column I is the current DUP (discounted unit price). My guess was that True was causing a problem, so I tried ""TRUE"", but that didn't help.
 
Just remove the quote marks around the "True"
I tried that first, but that doesn't work either. If it makes a difference, the code is running on a .csv file, so I'm not sure if "TRUE" (the string) is being evaluated the same as TRUE (boolean).
 
Upvote 0

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
FALSE wouldn't match either True or "TRUE" so I think you have a different problem.
 
Upvote 0
1) Can you copy paste here the "the normal SUMIFS formula" you have working ?
2) Can you show us what =ISLOGICAL(True_False_Cell_In_Here) returns ?
 
Upvote 0
While just about to drift off to sleep last night I suddenly realised I'd made a dumb mistake! The code is actually doing what I asked it to do, but my order of operations in the rest of the code was wrong. One quick repositioning of an IF statement and I'm now getting the results I was hoping for. Sorry for the hassle!
 
Upvote 0

Forum statistics

Threads
1,215,094
Messages
6,123,069
Members
449,092
Latest member
ipruravindra

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top