'Change cell value based on another cell value

i have one item with purchase and sale rate (Apple : $10 : $12 ). I have two cells A1 and D1. I want to do, if "purchase" in D1 then A1=$10 likewise "sale" in D1 then A1=$12 against item name (Apple).



Solution 1:[1]

In cell A1: =If(D1="purchase",10,If(D1="sale",12,"Error"))

This will put the proper amount in cell A1 and display Error if an invalid value is in D1.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 RetiredGeek