×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Try to use CHOOSE instead of IF
4

Try to use CHOOSE instead of IF

Try to use CHOOSE instead of IF

2
(OP)
Nothing drives one crazy than a series of IF inside an IF. But we usually start with Fortran and Basic programming before going into spreadsheet programming. By default, we love the IF(       )

I find the CHOOSE function in Excel a very useful tool. Those who havent tried, try it and those who have used it creatively lets learn more from you

Regards

IJR

RE: Try to use CHOOSE instead of IF

Couild you send a example?

RE: Try to use CHOOSE instead of IF

2
Example:

insead of:

=IF(A1=1,"one",IF(A1=2,"two",IF(A1=3,"three",">three")))

use the "choose" function:

=Choose(A1,"one","two","three")

The problem with the choose statement is that (as far as I know), if you enter a number > 3 into cell A1, you get a #VALUE error in the choose cell.  You can of course remidy this with a conditional statement (assuming no zero or negative numbers are to be entered):
 
=IF(A1<=3,Choose(A1,"one","two","three"),">three")

Hope this helps.

RE: Try to use CHOOSE instead of IF

Hi IRJ

I have developed this function in VBA (like select case in VBA)

Public Function FindCase(TxtStr, TxtDefaultValue, ParamArray VarAnsArray())

Dim i As Integer
FindCase = TxtDefaultValue

For i = 0 To UBound(VarAnsArray) - 1 Step 2
    If TxtStr = VarAnsArray(i) Then
        FindCase = VarAnsArray(i + 1)
        Exit Function
    End If
Next
End Function

we can use like this
=FINDCASE(A1,1,"A",1,"A2L",2,"A2S",1,"A4S",2)
IF cell A1 CONTAIN "A" RESULT WILL BE 1 (3rd & 4th arguments)
IF A1 CONTAIN "A2L" RESULT WILL BE 2(5th & 6th)
IF A1 CONTAIN "A2S" RESULT WILL BE 1(7th & 8th)
IF A1 CONTAIN "A4S" RESULT WILL BE 2(9th & 10th)
ELSE RESULT WILL BE 1 (second argument)

I tried to developed similer to select case statments in VBA

I have tried with string argument & it work OK.

Nitin Patel
India



RE: Try to use CHOOSE instead of IF

Thank you IJR & jproj!

I've been looking for this type of function for a LONG time.
Verrry cool.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login


Resources

Low-Volume Rapid Injection Molding With 3D Printed Molds
Learn methods and guidelines for using stereolithography (SLA) 3D printed molds in the injection molding process to lower costs and lead time. Discover how this hybrid manufacturing process enables on-demand mold fabrication to quickly produce small batches of thermoplastic parts. Download Now
Design for Additive Manufacturing (DfAM)
Examine how the principles of DfAM upend many of the long-standing rules around manufacturability - allowing engineers and designers to place a part’s function at the center of their design considerations. Download Now
Taking Control of Engineering Documents
This ebook covers tips for creating and managing workflows, security best practices and protection of intellectual property, Cloud vs. on-premise software solutions, CAD file management, compliance, and more. Download Now

Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close