Solved

How to modify my formula to compare a cell to a range?

Posted on 2014-10-10
8
89 Views
Last Modified: 2014-10-10
I am trying to replace the "(O2=$U$1)" portion of the below formula so that I can compare the value in cell "O2" with the range "Sites!D1:D53".

=SUM(AND(AND(O2=$U$1),AND(L2>=IF(RIGHT(S2,3)="VIP",0.5,11),L2<=IF(RIGHT(S2,3)="VIP",1,14),E2<>"NO KPP",F2<>"Closed")),A1)
0
Comment
Question by:kbay808
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 26

Expert Comment

by:ProfessorJimJam
ID: 40373617
can you upload a dummy file.  formula is kind of confusing with too many AND
0
 
LVL 27

Expert Comment

by:Glenn Ray
ID: 40373638
^ Agreeing with ProfessorJimJam.  The original function has too many - an incorrect - use of AND in the SUM function.  I'm surprised it yields any values.

What values are actually to be summed?

-Glenn
0
 
LVL 50

Accepted Solution

by:
barry houdini earned 500 total points
ID: 40374174
As Glenn says, you can take out the redundant ANDs and you'd get this version which should give the same results as you get now

=SUM(AND(O2=$U$1,L2>=IF(RIGHT(S2,3)="VIP",0.5,11),L2<=IF(RIGHT(S2,3)="VIP",1,14),E2<>"NO KPP",F2<>"Closed"),A1)

To do the change you want I assume that any match in the range Sites!D1:D53 will be sufficient, in which case use the COUNTIF function like this:

=SUM(AND(COUNTIF(Sites!D1:D53,O2)>0,L2>=IF(RIGHT(S2,3)="VIP",0.5,11),L2<=IF(RIGHT(S2,3)="VIP",1,14),E2<>"NO KPP",F2<>"Closed"),A1)

regards, barry
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 27

Expert Comment

by:Glenn Ray
ID: 40374225
Thanks, Barry.  

The issue I see is that, even after the redunant AND functions are removed, the whole SUM function is trying to sum up statements that evaluate to TRUE or FALSE:

=SUM(
    AND(
        COUNTIF(Sites!D1:D53,O2)>0,
        L2>=IF(RIGHT(S2,3)="VIP",0.5,11),
        L2<=IF(RIGHT(S2,3)="VIP",1,14),
        E2<>"NO KPP",
        F2<>"Closed"),
A1)

Why bother summing A1?
0
 

Author Comment

by:kbay808
ID: 40374230
I tried to make a sample file, but it's pulling sensitive data from multiple files.  I have been unable to duplicate it where the formula works.  The formula is used in a helper column to count the number of records that meet a certian criteria.  Please let me know if this is not possible without a sample file and I will delete this question.
0
 

Author Comment

by:kbay808
ID: 40374231
I did not see all of your updates.  I will try them out.
0
 

Author Closing Comment

by:kbay808
ID: 40374260
This worked.  Thank you very much.
0
 
LVL 50

Expert Comment

by:barry houdini
ID: 40374266
Hello Glenn,

I agree that it seems an odd formulation - the formula is effectively returning the value of A2, plus 1 if the AND function returns TRUE, because, for example,

=SUM(TRUE,4) = 5

It might be clearer to write it like this

=IF(AND(COUNTIF(Sites!D1:D53,O2)>0,L2>=IF(RIGHT(S2,3)="VIP",0.5,11),L2<=IF(RIGHT(S2,3)="VIP",1,14),E2<>"NO KPP",F2<>"Closed"),1,0)+A2

Perhaps kbay808 can confirm that the formula is supposed to work like that?

Of course that latter version would fail if A2 contains text, so the SUM approach has some merit if deliberately used to avoid an error in that situation

regards, barry
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question