+ Reply to Thread
Results 1 to 12 of 12

if-else HELP!

  1. #1
    Registered User
    Join Date
    03-27-2017
    Location
    No
    MS-Off Ver
    Yes
    Posts
    30

    if-else HELP!

    Is there a quick and easy way to get

    =IF($E$93=1,A3,IF($E$93=2,B3,IF($E$93=3,E3,IF($E$93=4,H3,IF($E$93=5,I3,IF($E$93=6,G3,IF($E$93=7,J3,IF($E$93=8,K3,IF($E$93=10,S3,IF($E$93=11,T3,""))))))))))

    to work better?

    I did this in the formula bar, but Im about to add more, and it's getting cumbersome, maybe some VBA?

  2. #2
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: if-else HELP!

    This is one way.

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Dave

  3. #3
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: if-else HELP!

    What is thuis being used on, can you share a sample workbook? I have a feeling these are headings that we may be able to use something else in
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  4. #4
    Registered User
    Join Date
    03-27-2017
    Location
    No
    MS-Off Ver
    Yes
    Posts
    30

    Re: if-else HELP!

    if cell E93 = 1, then put contents of A3, if 2 then B3, if 3 then B3 etc.... the problem is that I might have E93 = 30 then xxx.... but its a pain in the behind to add all this code, there has to be a faster and and cleaner way to put all if-else, if-then statements.

  5. #5
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: if-else HELP!

    We need you to upload a sample workbook to see what you are working with in context.


    To attach a file to your post,
    • click “Go Advanced” (next to Post Quick Reply – bottom right),
    • scroll down until you see “Manage Attachments”, click that,
    • click “Browse”.
    • select your file(s)
    • click “Upload”
    • click “Close window”
    • click “Submit Reply”
    • be sure to desensitize the data
    The file name will appear at the bottom of your reply.

  6. #6
    Registered User
    Join Date
    03-27-2017
    Location
    No
    MS-Off Ver
    Yes
    Posts
    30

    Re: if-else HELP!

    FlameRetired got it working!

  7. #7
    Registered User
    Join Date
    03-27-2017
    Location
    No
    MS-Off Ver
    Yes
    Posts
    30

    Re: if-else HELP!

    Quote Originally Posted by FlameRetired View Post
    This is one way.

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    thanks! this worked! how does it work? I see quotation marks, and my original code has value 9 missing, so how does it know what should follow?

  8. #8
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: if-else HELP!

    CHOOSE needs something in the 9th position. Since there are no 9s to pass I put in a "blank" or null string as a placeholder. The last is what to return if there is an error ... ie no places for the number in E93 ... for example 13.

    The best way to answer the rest of your question would be to look at the online help file (F1). Then search CHOOSE. It's actually a good explanation IMPO.
    Last edited by FlameRetired; 04-03-2017 at 01:40 AM.

  9. #9
    Registered User
    Join Date
    03-27-2017
    Location
    No
    MS-Off Ver
    Yes
    Posts
    30

    Re: if-else HELP!

    Quote Originally Posted by FlameRetired View Post
    CHOOSE needs something in the 9th position. Since there are no 9s to pass I put in a "blank" or null string as a placeholder. The last is what to return if there is an error ... ie no places for the number in E93 ... for example 13.

    The best way to answer the rest of your question would be to look at the online help file (F1). Then search CHOOSE. It's actually a good explanation IMPO.
    Thanks, I checked, but now my problem is
    =IFERROR(CHOOSE($E$93,A3,B3,E3,H3,I3,G3,J3,K3,"",S3,T3),"")

    to this:
    =IFERROR(CHOOSE($E$93,A3:K3,"",S3,T3),"")

    Can I do a range for the value?

  10. #10
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: if-else HELP!

    instead of everyone guessing, I suggest that you upload a small (clean) sample workbook (not a pic) of what you are working with, and what your expected outcome would look like.

  11. #11
    Registered User
    Join Date
    03-27-2017
    Location
    No
    MS-Off Ver
    Yes
    Posts
    30

    Re: if-else HELP!

    Quote Originally Posted by FDibbins View Post
    instead of everyone guessing, I suggest that you upload a small (clean) sample workbook (not a pic) of what you are working with, and what your expected outcome would look like.
    FlameRetired got it working, I can't upload.
    This works.
    =IFERROR(CHOOSE($E$93,A3,B3,E3,H3,I3,G3,J3,K3,"",S3,T3),"")

    But... I was wondering if I can shorten it by using ranges.
    so it looks more like this.
    =IFERROR(CHOOSE($E$93,A3:K3,"",S3,T3),"")

  12. #12
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: if-else HELP!

    I have to agree with Ford.

    My formula worked for the lone example you posted. That's all.

    As new information is revealed ...

    What problem are you encountering with upload? Are you following the instructions post #5?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1