Using the as-a-service approach for your business model allows you to grow your revenue stream with new practice areas, without forcing you to part ways with existing clients just because they don’t fit the mold of your new service offerings.

I have an Excel sheet trying to build a formula for the following. If s2>.01 then if x2="LIQUID" then if u2>=.01<=.1, "-TSRA", if u2>.1<.3,"TSRA", if u2>.3,"+TSRA", else if s2>=.01<.1,"-RA",s2>.1<=.3,"RA",s2>.3,"+RA", if x2="FROZEN" then if u2>=.01<=.1, "-TSSN", if u2>.1<.3,"TSSN", if u2>.3,"+TSSN", else if s2>=.01<.1,"-SN",s2>.1<=.3,"SN",s2>.3,"+SN", if x2="FREEZING" then if u2>=.01<=.1, "-TSFZRA", if u2>.1<.3,"TSFZRA", if u2>.3,"+TSFZRA", else if s2>=.01<.1,"-FZRA",s2>.1<=.3,"FZRA",s2>.3,"+FZRA", else if s2<.01, then ""

Experts Exchange Solution brought to you by

Enjoy your complimentary solution view.

Get this solution by purchasing an Individual license!
Start your 7-day free trial.

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Sample attached

EE_ComplicatedDecision.xlsm

EE_ComplicatedDecision.xlsm

ComplicatedDecision(S2, X2, U2)

If S2, X2 and U2 are in B5,C5 and D5 then put this in column Z. then you can copy paste the function call.

```
=complicatedDecision(B5,C5,D5)
```

correction

```
Public Function ComplicatedDecision(S2, X2, U2)
Dim sOutput As String
If X2 = "LIQUID" Then
If S2 > 0.01 Then
If U2 >= 0.01 And U2 <= 0.1 Then sOutput = "-TSRA"
If U2 >= 0.1 And U2 <= 0.3 Then sOutput = "TSRA"
If U2 > 0.3 Then sOutput = "+TSRA"
Else
If U2 >= 0.01 And U2 <= 0.1 Then sOutput = "-RA"
If U2 >= 0.1 And U2 <= 0.3 Then sOutput = "RA"
If U2 > 0.3 Then sOutput = "+RA"
End If
End If
If X2 = "FROZEN" Then
If S2 > 0.01 Then
If U2 >= 0.01 And U2 <= 0.1 Then sOutput = "-TSSN"
If U2 >= 0.1 And U2 <= 0.3 Then sOutput = "TSSN"
If U2 > 0.3 Then sOutput = "+TSSN"
Else
If U2 >= 0.01 And U2 <= 0.1 Then sOutput = "-SN"
If U2 >= 0.1 And U2 <= 0.3 Then sOutput = "SN"
If U2 > 0.3 Then sOutput = "+SN"
End If
End If
If X2 = "FREEZING" Then
If S2 > 0.01 Then
If U2 >= 0.01 And U2 <= 0.1 Then sOutput = "-TSFZRA"
If U2 >= 0.1 And U2 <= 0.3 Then sOutput = "TSFZRA"
If U2 > 0.3 Then sOutput = "+TSFZRA"
Else
If U2 >= 0.01 And U2 <= 0.1 Then sOutput = "-FZRA"
If U2 >= 0.1 And U2 <= 0.3 Then sOutput = "FZRA"
If U2 > 0.3 Then sOutput = "+FZRA"
End If
End If
If S2 < 0.01 Then
sOutput = ""
End If
ComplicatedDecision = sOutput
End Function
```

Sample.xlsx

Which columns correspond to S2, X2 and U2?

ComplicatedDecision(S2, X2, U2)

I call tell that X2 is column E because it contains LIQUID, but not sure about the others.

If all the parameters are not specified, then the result is blank.

Sample2.xlsm

since that is what you are needing, then I think the first S2 if statement needs to be less than instead of greater than.

```
Public Function ComplicatedDecision(S2, X2, U2)
Dim sOutput As String
If X2 = "LIQUID" Then
If S2 < 0.01 Then
If U2 >= 0.01 And U2 <= 0.1 Then sOutput = "-TSRA"
If U2 >= 0.1 And U2 <= 0.3 Then sOutput = "TSRA"
If U2 > 0.3 Then sOutput = "+TSRA"
Else
If S2 >= 0.01 And S2 <= 0.1 Then sOutput = "-RA"
If S2 >= 0.1 And S2 <= 0.3 Then sOutput = "RA"
If S2 > 0.3 Then sOutput = "+RA"
End If
End If
If X2 = "FROZEN" Then
If S2 < 0.01 Then
If U2 >= 0.01 And U2 <= 0.1 Then sOutput = "-TSSN"
If U2 >= 0.1 And U2 <= 0.3 Then sOutput = "TSSN"
If U2 > 0.3 Then sOutput = "+TSSN"
Else
If S2 >= 0.01 And S2 <= 0.1 Then sOutput = "-SN"
If S2 >= 0.1 And S2 <= 0.3 Then sOutput = "SN"
If S2 > 0.3 Then sOutput = "+SN"
End If
End If
If X2 = "FREEZING" Then
If S2 < 0.01 Then
If U2 >= 0.01 And U2 <= 0.1 Then sOutput = "-TSFZRA"
If U2 >= 0.1 And U2 <= 0.3 Then sOutput = "TSFZRA"
If U2 > 0.3 Then sOutput = "+TSFZRA"
Else
If S2 >= 0.01 And S2 <= 0.1 Then sOutput = "-FZRA"
If S2 >= 0.1 And S2 <= 0.3 Then sOutput = "FZRA"
If S2 > 0.3 Then sOutput = "+FZRA"
End If
End If
If S2 < 0.01 Then
sOutput = ""
End If
ComplicatedDecision = sOutput
End Function
```

Sample03.xlsm
Sample03.xlsm

It seems that if U2 meets the conditions, then you want a TSRA type otherwise if S2 meets the conditions an RA Type.

I don't know what TSRA or RA mean, I'm just trying to interpret the specs you have given and produce code that meets the conditions.

Here is another approach using a true false boolean to toggle where the RA test is done.

```
If X2 = "LIQUID" Then
sOutput = ""
bRule1 = False
If U2 >= 0.01 And U2 <= 0.1 Then sOutput = "-TSRA"
If U2 >= 0.1 And U2 <= 0.3 Then sOutput = "TSRA"
If U2 > 0.3 Then sOutput = "+TSRA"
If sOutput = "" Then bRule1 = True
If bRule1 = True Then
If S2 >= 0.01 And S2 <= 0.1 Then sOutput = "-RA"
If S2 >= 0.1 And S2 <= 0.3 Then sOutput = "RA"
If S2 > 0.3 Then sOutput = "+RA"
End If
End If
```

Sample04.xlsm
Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Microsoft Excel

From novice to tech pro — start learning today.

Experts Exchange Solution brought to you by

Enjoy your complimentary solution view.

Get this solution by purchasing an Individual license!
Start your 7-day free trial.

Open in new window