Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2014-10-10
8
Medium Priority
?
93 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 27

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 2000 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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!
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

670 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