Returns value if...

tonyrensya

New Member
Joined
Jul 24, 2013
Messages
21
Office Version
  1. 2019
Platform
  1. Windows
  2. MacOS
Hello all,

I'm using Excel 2019, here is my problem to be solve:
If value is A1 or A2, returns 1
If value is B1 or B2, returns 0

Datavalue
TomA1
JohnB1
MaryA2
MayB2

OutcomeReturns
Mary1
Tom1
May0
John0

Great thanks to all :)
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
If value is A1 or A2, returns 1
If value is B1 or B2, returns 0
And, how or from where are you getting this value A1 etc...

Also, if you are using Excel 2019 update same in your profile too so that others are able to see and deliver solution accordingly.
 
Upvote 0
Hi, like this maybe:

Book1
AB
1Datavalue
2TomA1
3JohnB1
4MaryA2
5MayB2
6
7OutcomeReturns
8Mary1
9Tom1
10May0
11John0
Sheet1
Cell Formulas
RangeFormula
B8:B11B8=0+OR(VLOOKUP(A8,$A$2:$B$5,2,0)={"A1","A2"})
 
Upvote 0
Thank you very much, it works as it suppose.
If there's no value be found in vlookup, could it be the cell become blank instead of 0 ?
 
Upvote 0
And, how or from where are you getting this value A1 etc...

Also, if you are using Excel 2019 update same in your profile too so that others are able to see and deliver solution accordingly.

the value "A1" ,"B1" is just a text, I'm sorry for misleading.

Thank you for reminding. I've changed my profile as well
 
Upvote 0
Do you mean when a match can not be found in the "data" volume or when a match can be found but the "value" column is blank?
I mean if the "value" column is blank, then the "returns" column shows blank instead of 0
Thank you very much!
 
Upvote 0
Hi, you could try like this:

Book1
AB
1Datavalue
2TomA1
3JohnB1
4MaryA2
5Fred
6MayB2
7
8OutcomeReturns
9Mary1
10Tom1
11May0
12Fred 
13John0
Sheet1
Cell Formulas
RangeFormula
B9:B13B9=IF(VLOOKUP(A9,$A$2:$B$6,2,0)="","",0+OR(VLOOKUP(A9,$A$2:$B$6,2,0)={"A1","A2"}))
 
Upvote 0
Hi, you could try like this:

Book1
AB
1Datavalue
2TomA1
3JohnB1
4MaryA2
5Fred
6MayB2
7
8OutcomeReturns
9Mary1
10Tom1
11May0
12Fred 
13John0
Sheet1
Cell Formulas
RangeFormula
B9:B13B9=IF(VLOOKUP(A9,$A$2:$B$6,2,0)="","",0+OR(VLOOKUP(A9,$A$2:$B$6,2,0)={"A1","A2"}))
It only returns 1 if the value is A1, but not A2, its there anything wrong?
 
Upvote 0
It only returns 1 if the value is A1, but not A2, its there anything wrong?
In post#8, the first row of the results table contains "Mary" whose value in the data table is "A2" and the formula returns 1 as expected - perhaps you can post some sample data that demonstrates the problem?
 
Upvote 0

Forum statistics

Threads
1,215,069
Messages
6,122,958
Members
449,096
Latest member
Anshu121

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