#1   Report Post  
Al
 
Posts: n/a
Default Case function

Does Excel have a function similar to the "Case" command in other programming
languages?
  #2   Report Post  
Bob Phillips
 
Posts: n/a
Default

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" wrote in message
...
Does Excel have a function similar to the "Case" command in other

programming
languages?



  #3   Report Post  
JE McGimpsey
 
Posts: n/a
Default

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 ,
"Al" wrote:

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

  #4   Report Post  
Al
 
Posts: n/a
Default

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" wrote in message
...
Does Excel have a function similar to the "Case" command in other

programming
languages?




  #5   Report Post  
David McRitchie
 
Posts: n/a
Default

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" wrote in message ...
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" wrote in message
...
Does Excel have a function similar to the "Case" command in other

programming
languages?








  #6   Report Post  
Bob Phillips
 
Posts: n/a
Default

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" wrote in message
...
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" wrote in message
...
Does Excel have a function similar to the "Case" command in other

programming
languages?






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
reminder notifications in a column L Mieth Excel Discussion (Misc queries) 6 June 10th 05 11:00 AM
How can i change this VBA project According to Indian Numeric Rao Ratan Singh Excel Discussion (Misc queries) 1 April 21st 05 07:53 PM
Dynamic Formulas with Dynamic Ranges Ralph Howarth Excel Worksheet Functions 5 January 21st 05 08:44 AM
Amount or Numbers in Words ron New Users to Excel 6 December 24th 04 07:32 PM
Is there a formula to spell out a number in excel? Sha-nay-nay Excel Worksheet Functions 2 December 18th 04 09:25 PM


All times are GMT +1. The time now is 10:18 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"