Apply different formulas depending on cell value

AxelU

New Member
Joined
Sep 30, 2014
Messages
5
Hi,

I am looking for a way to dynamically change which formula is used depending on the value in another cell, example:

If value is betweenUse formula
0-40ROUND
40-100ROUNDUP
100-1000ROUND
1000-10000ROUNDDOWN

<colgroup><col><col></colgroup><tbody>
</tbody>

I am looking for a solution that does not require endless if-statements. Rather looking for a solution where one specifies the formula to be used in a range which is the applied through an index-match-statement or similar. I have tried using the INDIRECT function but it does not seem to convert the text into different formulas.

Any help is well appreciated!

/Axel
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
I can think of two ways of doing it:
1. Use a Nested IF statement in Excel (it is not endless, you only have 4 conditions, so it shouldn't be that big of a deal)
2. Create your own User Defined Function to do it (using VBA)
 
Upvote 0
You need to redefine your limits
From your description

0-40 ROUND
40-100 ROUNDUP

So if the value is exactly 40
you want BOTH ROUND AND ROUNDUP

I bet you dont.

Take another look at (all) your limits
 
Last edited:
Upvote 0
Thank you for your replies.

The attached was just an example, please ignore the intervalls and number of conditions. What I want to know is if it is possible to fetch a different formula for a cell, deepening on another cells value without using if-statements.

For example:

If B4 is over 10 i want to ROUNDDOWN the value
if B4 is below 10 I want to ROUNDUP the value

There will be numerous variations of this why I do not want to use if-statements. The best would be some kind of list of formulas that could be concated to cell references.

Thanks in advance!

Br,
Axel
 
Upvote 0
The attached was just an example, please ignore the intervalls and number of conditions. What I want to know is if it is possible to fetch a different formula for a cell, deepening on another cells value without using if-statements.

Nested IF would be the easiest for my thinking, but if you really don't want IF for some reason, you could use something like

=CHOOSE(MATCH(C2,{0,41,101,1001,10001}),ROUND(A1,0),ROUNDUP(A1,0),ROUND(A1,0),ROUNDDOWN(A1,0))
 
Last edited:
Upvote 0
The UDF option may look something like this:
Code:
Function MyRound(myValue As Double) As Double

    Application.Volatile
    
    Select Case myValue
        Case Is < 40
            MyRound = Round(myValue, 0)
        Case Is < 100
            MyRound = Application.WorksheetFunction.RoundUp(myValue, 0)
        Case Is < 1000
            MyRound = Round(myValue, 0)
        Case Is < 10000
            MyRound = Application.WorksheetFunction.RoundDown(myValue, 0)
        Case Else
            MyRound = myValue
    End Select
                
End Function
Then just use it like any other Excel function on your sheet, i.e.
=MyRound(A1)
 
Upvote 0

Forum statistics

Threads
1,215,338
Messages
6,124,358
Members
449,155
Latest member
ravioli44

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