+ Reply to Thread
Results 1 to 6 of 6

Case function

  1. #1
    Al
    Guest

    Case function

    Does Excel have a function similar to the "Case" command in other programming
    languages?

  2. #2
    JE McGimpsey
    Guest

    Re: Case function

    XL itself doesn't, since XL is not a programming language. It does have
    IF() and CHOOSE() functions, which can be used similarly.

    OTOH, VBA has a Select Case statement that is pretty well explained in
    VBA Help.

    In article <F99619C8-E32C-4B61-9C81-5663E8CE879C@microsoft.com>,
    "Al" <Al@discussions.microsoft.com> wrote:

    > Does Excel have a function similar to the "Case" command in other programming
    > languages?


  3. #3
    Bob Phillips
    Guest

    Re: Case function

    In VBA, yes


    Select Case myVal
    Case 1: 'do something
    Case 2: 'do something else
    Case Else; ' exception
    End Select

    --

    HTH

    RP
    (remove nothere from the email address if mailing direct)


    "Al" <Al@discussions.microsoft.com> wrote in message
    news:F99619C8-E32C-4B61-9C81-5663E8CE879C@microsoft.com...
    > Does Excel have a function similar to the "Case" command in other

    programming
    > languages?




  4. #4
    Al
    Guest

    Re: Case function

    Bob,
    Pardon my ignorance but how do I call the myVal routine from within Excel?

    "Bob Phillips" wrote:

    > In VBA, yes
    >
    >
    > Select Case myVal
    > Case 1: 'do something
    > Case 2: 'do something else
    > Case Else; ' exception
    > End Select
    >
    > --
    >
    > HTH
    >
    > RP
    > (remove nothere from the email address if mailing direct)
    >
    >
    > "Al" <Al@discussions.microsoft.com> wrote in message
    > news:F99619C8-E32C-4B61-9C81-5663E8CE879C@microsoft.com...
    > > Does Excel have a function similar to the "Case" command in other

    > programming
    > > languages?

    >
    >
    >


  5. #5
    David McRitchie
    Guest

    Re: Case function

    Hi Al,
    It is part of a macro, here is an example that is an event macro
    http://www.mvps.org/dmcritchie/excel/event.htm#case
    even though event macros are not the most common macros they
    are easier to install. This particular macro would be triggered by
    entering a constant into a cell (as opposed to a value changing due
    to a formula).
    installed by right click on sheet tab, view code, place code inside.

    Some information on standard macro installation and use
    http://www.mvps.org/dmcritchie/excel/getstarted.htm
    ---
    HTH,
    David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
    My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
    Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

    "Al" <Al@discussions.microsoft.com> wrote in message news:847DEB3A-D181-4E78-AA51-68AEE7565833@microsoft.com...
    > Bob,
    > Pardon my ignorance but how do I call the myVal routine from within Excel?
    >
    > "Bob Phillips" wrote:
    >
    > > In VBA, yes
    > >
    > >
    > > Select Case myVal
    > > Case 1: 'do something
    > > Case 2: 'do something else
    > > Case Else; ' exception
    > > End Select
    > >
    > > --
    > >
    > > HTH
    > >
    > > RP
    > > (remove nothere from the email address if mailing direct)
    > >
    > >
    > > "Al" <Al@discussions.microsoft.com> wrote in message
    > > news:F99619C8-E32C-4B61-9C81-5663E8CE879C@microsoft.com...
    > > > Does Excel have a function similar to the "Case" command in other

    > > programming
    > > > languages?

    > >
    > >
    > >




  6. #6
    Bob Phillips
    Guest

    Re: Case function

    It is not a routine, it is a variable being tested for in the case
    statement.It applies to VBA, not to Excel itself.

    If you want a case type function in a worksheet, there isn't one. There are
    many lookup functions that might do what you want, but you would need to
    present the problem to tell.

    --

    HTH

    RP
    (remove nothere from the email address if mailing direct)


    "Al" <Al@discussions.microsoft.com> wrote in message
    news:847DEB3A-D181-4E78-AA51-68AEE7565833@microsoft.com...
    > Bob,
    > Pardon my ignorance but how do I call the myVal routine from within Excel?
    >
    > "Bob Phillips" wrote:
    >
    > > In VBA, yes
    > >
    > >
    > > Select Case myVal
    > > Case 1: 'do something
    > > Case 2: 'do something else
    > > Case Else; ' exception
    > > End Select
    > >
    > > --
    > >
    > > HTH
    > >
    > > RP
    > > (remove nothere from the email address if mailing direct)
    > >
    > >
    > > "Al" <Al@discussions.microsoft.com> wrote in message
    > > news:F99619C8-E32C-4B61-9C81-5663E8CE879C@microsoft.com...
    > > > Does Excel have a function similar to the "Case" command in other

    > > programming
    > > > languages?

    > >
    > >
    > >




+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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