Excel VBA Course
Excel VBA Course - From Beginner to Expert

200+ Video Lessons
50+ Hours of Video
200+ Excel Guides

Become a master of VBA and Macros in Excel and learn how to automate all of your tasks in Excel with this online course. (No VBA experience required.)

View Course

Sumif function not working. Returning zero as result

0

In sheet2, Cells C5 and E5 has formulas:

=SumIf(Sheet1!B2:B27,">7 Days", Sheet1!D2:D27)

=SumIf(Sheet1!B2:B27,">30 Days", Sheet1!D2:D27)

is returning 0. Any idea why this is happening?

Answer
Discuss

Discussion

Dr Liss

Please attach the workbook you are referring to and (before solutions are suggested) explain if the data in B2:B27 is imported (as in some of your previous questions).
John_Ru (rep: 6142) Aug 10, '21 at 12:29 pm
Add to Discussion

Answers

0

Dr Liss

Not sure what's happening here but suspect that your use of the > symbol is causing Excel to try to evaluate the text entries mathematically.

If the criteria periods are all different numbers of days, you can use the * wildcard on the strings, as follows:

=SumIf(Sheet1!B2:B27,"*7*", Sheet1!D2:D27)
=SumIf(Sheet1!B2:B27,"*30*", Sheet1!D2:D27)
Discuss

Discussion

Did you solve this separately?
John_Ru (rep: 6142) Aug 13, '21 at 10:54 am
Add to Discussion
0

There seems to be nothing wrong your your formulas. Therefore the flaw must be in the data (which you don't show us). "7 Days" is a string in your formula. both "8 Days" and "7 Trays" would evaluate to being "greater than". In either case, it's a string evaluation which is different from ">"&7&" Days".

However, if I had any hand in creating the column you search I would have a cell format like "0 Days", meaning that the cell value would be only 7 and the "Days" being added by the format. In such a case you would need to look for the number only, like ...

=SumIf(Sheet1!B2:B27,">" & 7, Sheet1!D2:D27)

Whatever you do, keep track of the fact that the formula can only find what is there. Therefore please look at the values being searched.

Discuss
0

Dear Liss,

Please attach the workbook you are referring to. I think I can solve this.

Discuss

Discussion

Asif

Good that you may have a solution but for future reference, please note that your statement above isn't an Answer (i.e. a solution) to the question, it's a discussion point/request. You'll see that I already asked the user for the workbook (yesterday, see  Discussion attached to the Question).
John_Ru (rep: 6142) Aug 11, '21 at 3:05 pm
Add to Discussion
0

I need more Excel features for software development. Tell me where it is better to write about this question

Regards
software development

[link removed]
Post Edited
Personal Information: Personal information was removed from the post, such as an email address.
Discuss

Discussion

You can ask a question if you want by clicking the Ask Question button in the forum, but you cannot promote your software here, which is why your link was removed.
don (rep: 1989) Sep 27, '21 at 3:37 pm
Add to Discussion


Answer the Question

You must create an account to use the forum. Create an Account or Login