Results 1 to 2 of 2

Thread: MS Excel Question: IF Function

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2004
    Location
    Right here
    Posts
    275

    MS Excel Question: IF Function

    Is there a better way than this to code IF statements in a worksheet?

    Code:
    =IF(H8=1, A1, IF(H8=2, A2, IF(H8=3, A3, A4)))
    As the code shows, the common reference cell is H8 and the IF statement checks it's value (from a range of 1-3) and then makes the target cell equal one out of a range of cells depending on the outcome.

    This is a short example but I have some very long and complex IF statements that use this method and was wondering if there was a way to simplify e.g. by using array formulas or something similar?

    Something along the lines of:

    Code:
    =[IF(H8 = 1;2;3, A1;A2;A3, A4)]
    That obviously doesn't work but that's the kind of thing I was thinking.

    Cheers
    -Rob
    http://www.sudsolutions.com

  2. #2
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: MS Excel Question: IF Function

    You can use either the VLOOKUP or HLOOKUP functions. They will check a rnage of cells for a particular value and make it equal to a cell in the range. Have a look at the attached file for an example.
    Attached Files Attached Files
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

Posting Permissions

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



Click Here to Expand Forum to Full Width