convert formula to code please

d0wnt0wn

Well-known Member
Joined
Oct 28, 2002
Messages
771
is there a way that I can convert this formula to code? it seems it is too long now and the last part of the formula does not work

=IF(B14="cedar conversion",ROUNDUP(B16/10,0),IF(B14="plywood over shiplap tear off",ROUNDUP(B16/10,0),IF(B14="2 layer plywood over shiplap",ROUNDUP(B16/10,0),IF(B14="3 layer plywood over shiplap",ROUNDUP(B16/10,0),IF(B14="1 layer on cedar tear off",ROUNDUP(B16/10,0),IF(B14="2 layer on cedar tear off",ROUNDUP(B16/10,0),IF(B14="3 layer on cedar tear off",ROUNDUP(B16/10,0),"")))))))
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Instead of nesting it, since all the conditions are resulting in the same calculation, why not use OR, i.e.
=IF(OR(condition1, condition2, condition3, ...),ROUNDUP(B16/10,0),"")
 
Upvote 0
is there a way that I can convert this formula to code? it seems it is too long now and the last part of the formula does not work

=IF(B14="cedar conversion",ROUNDUP(B16/10,0),IF(B14="plywood over shiplap tear off",ROUNDUP(B16/10,0),IF(B14="2 layer plywood over shiplap",ROUNDUP(B16/10,0),IF(B14="3 layer plywood over shiplap",ROUNDUP(B16/10,0),IF(B14="1 layer on cedar tear off",ROUNDUP(B16/10,0),IF(B14="2 layer on cedar tear off",ROUNDUP(B16/10,0),IF(B14="3 layer on cedar tear off",ROUNDUP(B16/10,0),"")))))))

How many conditions do you have where your don't round B16/10? It may be easier to write a formula when those conditions are not met....
 
Upvote 0
its about the same amount... let me try the 1f(or( way as suggested and I will report back
 
Upvote 0
Hi Joe it returns a #value error using that method
Also, please post your formula attempt, as well as the values in B14 and B16.
 
Upvote 0
Hi Joe

Here is the formula I tried =IF(OR("Cedar conversion"),ROUNDUP(B16/10,0),"")

Cedar conversion is in cel B14

50 is in cel B16
 
Upvote 0
You forgot your B14 reference in your formula.
Also, there is no sense in using OR with only one condition. I assume you will be adding your other conditions, i.e.
=IF(OR(B14="Cedar conversion",B14="plywood over shiplap tear off",B14="2 layer plywood over shiplap",...),ROUNDUP(B16/10,0),"")
 
Upvote 0

Forum statistics

Threads
1,213,543
Messages
6,114,243
Members
448,555
Latest member
RobertJones1986

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