Better way required to write 1 formula

hsandeep

Well-known Member
Joined
Dec 6, 2008
Messages
1,224
Office Version
  1. 2010
Platform
  1. Windows
  2. Mobile
Any better 'way' to write the below formula:

=IF(AGG2=100,"i",IF(AGG2=200,"j",IF(AGC2=100,"p",IF(AGC2=-100,"q",IFERROR(CHOOSE(B2,"J","K","L","M"),0)))))

Thanks in adv.
 

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.
I'm just giving you choices. If you want to create a user defined function instead, it's easier to read and easier to make changes.

Code:
Function GetChoice(R1 As Range, R2 As Range, R3 As Range) As Variant  

  
  

  If R1.Value = 100 Then
    GetChoice = "i"
  ElseIf R1.Value = 200 Then
    GetChoice = "j"
  ElseIf R2.Value = 100 Then
    GetChoice = "p"
  ElseIf R2.Value = -100 Then
    GetChoice = "q"
  ElseIf R3.Value = 1 Then
    GetChoice = "j"
  ElseIf R3.Value = 2 Then
    GetChoice = "k"
  ElseIf R3.Value = 3 Then
    GetChoice = "l"
  ElseIf R3.Value = 4 Then
    GetChoice = "m"
  Else
    GetChoice = 0
  End If
  
End Function

The cell formula would look something like this: =GetChoice(AGG2,AGC2,B2)
 
Upvote 0
Add this line to the code if you want it to always refresh with cell changes: Application.Volatile
 
Upvote 0
I want to use 'another' formula for the 'first 2' IFs (in the formula).
 
Upvote 0

Forum statistics

Threads
1,216,749
Messages
6,132,496
Members
449,730
Latest member
SeanHT

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