Filling an Excel Cell based on data in two other cells
Excel is a powerful tool that can help you organize and analyze your data. One common task in Excel is filling a cell based on the values in two other cells. In this article, we will explain how to achieve this using simple formulas.
Using the IF function
The IF function in Excel allows you to perform a logical test and return different values based on the result of that test. This function is perfect for filling a cell based on the data in two other cells.
Let's say you have two cells, A1 and B1, and you want to fill cell C1 based on the values in A1 and B1. Here's how you can do it:
- Select the cell C1 where you want the result to appear.
- Type the following formula:
=IF(A1="Value1", B1, "Value2") - Replace "Value1" with the value you want to test in cell A1.
- Replace "Value2" with the value you want to fill in cell C1 if the test in cell A1 fails.
For example, let's say you have a list of products in column A and their corresponding prices in column B. You want to fill column C with the text "Expensive" if the price is greater than $100, and "Affordable" otherwise. Here's how you can do it:
- Select the cell C1 where you want the result to appear.
- Type the following formula:
=IF(B1>100, "Expensive", "Affordable")
Now, when the price in cell B1 is greater than $100, cell C1 will display "Expensive". Otherwise, it will display "Affordable".
Using the CONCATENATE function
The CONCATENATE function in Excel allows you to combine the contents of two or more cells into one cell. This function can be useful when you want to fill a cell based on the values in two other cells.
Let's say you have two cells, A1 and B1, and you want to fill cell C1 with the combined text from A1 and B1. Here's how you can do it:
- Select the cell C1 where you want the result to appear.
- Type the following formula:
=CONCATENATE(A1, " ", B1)
This formula will combine the text in cell A1, a space character, and the text in cell B1 into cell C1.
Using the VLOOKUP function
The VLOOKUP function in Excel allows you to search for a value in the first column of a range of cells and return a value from a different column in the same row. This function can be handy when you want to fill a cell based on the values in two other cells.
Let's say you have a list of products in column A, their corresponding prices in column B, and a discount rate in cell D1. You want to fill column C with the discounted price based on the product name in column A and the discount rate in cell D1. Here's how you can do it:
- Select the cell C1 where you want the result to appear.
- Type the following formula:
=VLOOKUP(A1, A1:B10, 2, FALSE)*(1-D1) - Replace "A1:B10" with the range that contains your product names and prices.
This formula will search for the product name in cell A1 in the range A1:B10, and return the corresponding price from column B. It then multiplies the price by (1 - discount rate) to calculate the discounted price.
These are just a few examples of how you can fill a cell based on data in two other cells using simple formulas in Excel. By understanding the power of Excel's functions, you can automate and streamline your data analysis tasks.
References
| Source | Link |
|---|---|
| Microsoft Excel Support | https://support.microsoft.com/en-us/excel |
| Excel Easy | https://www.excel-easy.com/ |
| Exceljet | https://exceljet.net/ |