2

I have a scenario where I need to identify a result. Below is a sample excel cells with three columns Prod Name, Qty and Result.

Prod Name    Qty     Result
abc          10 
zyz          9  
test1        5  

If the product name is abc or zyz and its qty is 10, then I need to add text Refill in Column Result.

For any other product. in this case test1 and its qty is 5, then I need to add the same text Refill in Column Result.

Else it will always be Don't Refill

1
  • What formula have you tried? What problem have you encountered? As it is, you have given a specification but haven't actually asked a question. Commented Jun 1, 2018 at 13:28

2 Answers 2

4

Try this formula:

=IF(OR(AND(OR(A1="abc", A1="xyz"), B1=10), AND(AND(A1<>"abc", A1<>"xyz"), B1=5)),
    "Refill",
    "Don't Refill")
Sign up to request clarification or add additional context in comments.

4 Comments

For any other product. in this case test1 I think that there are more than just that one case for 5
@ScottCraner Good catch. You've been staring into spreadsheets for way too long :-)
I find it relaxing after spending too much time in sql databases all day. Excel is a little simpler.
Just an FYI: OR(A1="abc", A1="xyz") can be shortened to OR(A2={"abc","zyz"}) and AND(AND(A1<>"abc", A1<>"xyz"), B1=5) to AND(A2<>{"abc","zyz"},B2=5) without the need of CSE.
0

The formula provided by Tim above should work nicely, but if you're looking for VBA approach:

(Presuming the data is in a table called Table1 in a sheet called Sheet1)

Private Sub comb_products()

  Dim tbl As ListObject: Set tbl = Sheets("Sheet1").ListObjects("Table1")

For Each Rng In tbl.ListColumns(1).DataBodyRange


 If ((Rng.Value2 = "abc" Or Rng.Value2 = "zyz") And Rng.Offset(0, 1).Value2 = 10) Then
        Rng.Offset(0, 2).Value2 = "Refill"
 ElseIf ((Rng.Value2 <> "abc" Or Rng.Value2 <> "zyz") And Rng.Offset(0, 1).Value2 = 5) Then
        Rng.Offset(0, 2).Value2 = "Refill"
 Else
        Rng.Offset(0, 2).Value2 = "Don't refill"
 End If

Next Rng

End Sub

Result as expected:

enter image description here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.