Pickup Value

Jonathan Lee

New Member
Joined
Feb 22, 2015
Messages
33
Office Version
  1. 2016
Platform
  1. Windows
Dear Sifus,

How can I pick up desired value in a range of cells?

Example:

Column A Column B Column C
Basket 1 Apple
Basket 1 Apple
Basket 1 Orange
Basket 2 Apple
Basket 2 Apple
Basket 2 Apple

Needs to return the value in column C:

Basket 1 Orange
Basket 2 Apple

Rule is, as long as there are oranges in the basket, returns orange. Else Apple.

Note, there could be other fruits as well but I am only taking oranges and apples. If there are other fruits, other than oranges and apples, returns apple.

Thanks for your help.
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Like this?

21 10 19.xlsm
ABC
1
2Basket 1AppleOrange
3Basket 1AppleOrange
4Basket 1OrangeOrange
5Basket 2AppleApple
6Basket 2AppleApple
7Basket 2AppleApple
Apples
Cell Formulas
RangeFormula
C2:C7C2=IF(COUNTIFS(A$2:A$7,A2,B$2:B$7,"Orange"),"Orange","Apple")
 
Upvote 0
Like this?

21 10 19.xlsm
ABC
1
2Basket 1AppleOrange
3Basket 1AppleOrange
4Basket 1OrangeOrange
5Basket 2AppleApple
6Basket 2AppleApple
7Basket 2AppleApple
Apples
Cell Formulas
RangeFormula
C2:C7C2=IF(COUNTIFS(A$2:A$7,A2,B$2:B$7,"Orange"),"Orange","Apple")
Thanks for the prompt reply.

I have another scenario.

I need to return a blank if the basket is empty. Please advise. Thanks in advance.
 
Upvote 0
I need to return a blank if the basket is empty.
Like this? (If not, sample data and expected results please)

21 10 19.xlsm
ABC
1
2Basket 1AppleOrange
3Basket 1AppleOrange
4Basket 1OrangeOrange
5Basket 2AppleApple
6Basket 2AppleApple
7Basket 2AppleApple
8Basket 3 
9Basket 3 
10Basket 3 
Apples (2)
Cell Formulas
RangeFormula
C2:C10C2=IF(COUNTIFS(A$2:A$10,A2,B$2:B$10,"Orange"),"Orange",IF(COUNTIFS(A$2:A$10,A2,B$2:B$10,"?*"),"Apple",""))
 
Upvote 0
Solution
Like this? (If not, sample data and expected results please)

21 10 19.xlsm
ABC
1
2Basket 1AppleOrange
3Basket 1AppleOrange
4Basket 1OrangeOrange
5Basket 2AppleApple
6Basket 2AppleApple
7Basket 2AppleApple
8Basket 3 
9Basket 3 
10Basket 3 
Apples (2)
Cell Formulas
RangeFormula
C2:C10C2=IF(COUNTIFS(A$2:A$10,A2,B$2:B$10,"Orange"),"Orange",IF(COUNTIFS(A$2:A$10,A2,B$2:B$10,"?*"),"Apple",""))
Thanks… it works :)
 
Upvote 0
You're welcome. Thanks for the follow-up. :)
 
Upvote 0

Forum statistics

Threads
1,214,588
Messages
6,120,412
Members
448,960
Latest member
AKSMITH

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