If a certain text is in a cell, multiply a different cell by a number

kefin

New Member
Joined
May 4, 2022
Messages
2
Office Version
  1. 2021
Platform
  1. MacOS
Hello

So I am dealing with a large amount of data. I have product colours in one column and the colour weight in another column.
So if a product is black, I want to multiply the weight of the colour by 4. But if it is green, I want to multiply the weight by 3.
The closest I could get is =IF(C2="Black",D2*4)
The problem with this is every other cell responds with FALSE. How do I specify for each different colour?
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Welcome to the Board!

You get FALSE returned if your condition is not met and you have not told it what to return when that happens.
If you wanted it to return nothing instead, you could do:
Excel Formula:
=IF(C2="Black",D2*4,"")

Now, if you want to add in the green condition, one way is to use a nested IF like this:
Excel Formula:
=IF(C2="Black",D2*4,IF(C2="Green",D2*3,""))

If you have more than a few colors you need to work into the formula, I would recommend either setting up a lookup table and using VLOOKUP to return the factor to multiply by (see: How to use the Excel VLOOKUP function | Exceljet).
 
Last edited:
Upvote 0
Solution
Welcome to the Board!

You get FALSE returned if your condition is not met and you have not told it what to return when that happens.
If you wanted it to return nothing instead, you could do:
Excel Formula:
=IF(C2="Black",D2*4,"")

Now, if you want to add in the green condition, one way is to use a nested IF like this:
Excel Formula:
=IF(C2="Black",D2*4,IF(C2="Green",D2*3,""))

If you have more than a few colors you need to work into the formula, I would recommend either setting up a lookup table and using VLOOKUP to return the factor to multiply by (see: How to use the Excel VLOOKUP function | Exceljet).
You are a godsend, my friend! Thank you very much!
 
Upvote 0
You are welcome.
Glad I was able to help!
 
Upvote 0

Forum statistics

Threads
1,214,522
Messages
6,120,025
Members
448,939
Latest member
Leon Leenders

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