Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.1k views
in Technique[技术] by (71.8m points)

Two almost exact lists: If the column at the right have a specific value, then copy it at the left (excel)

I am working with excel.

I have almost two identical columns and I need some of the different results of the column at the right to be at the column at the left.

They look like this....

A      B
Yes    Yes
No     No
No     Maybe
Yes    Yes
Yes    Maybe
No     NA
Yes    Yes
No     Maybe
Yes    NA
No     No

I need new column A that contains the "Maybe" and maintain the values of the A when is NA in the B column... So it should look like this....

A      B        C
Yes    Yes      Yes
No     No       No
No     Maybe    Maybe
Yes    Yes      Yes
Yes    Maybe    Maybe
No     NA       No
Yes    Yes      Yes
No     Maybe    Maybe
Yes    NA       Yes
No     No       No

I have tried different things with IF formula, Match formula and Vlookup formula, but I have not reach a solution.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

If your sample data covers all possible combinations of Yes, No, NA, & Maybe then you can recreate your output column using the below formula and filling down as necessary

=IF(B2="NA",A2,IF(B2="Maybe",B2,B2))

which can be simplified to

=IF(B1="NA",A1,B1)

enter image description here


If you have not provided all combinations of values then this likely will not work and you will need to update your sample data. This solution assumes:

  1. Column A can only contain Yes & No
  2. Column B can only contain Yes & No & NA & Maybe
  3. There is no instance where one column is Yes and the other is No

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...