PC Review


Reply
Thread Tools Rate Thread

Case Statements in Excel 2003

 
 
Alex
Guest
Posts: n/a
 
      3rd Apr 2008
Stupid question, but is it possible to do a Case statement in Excel
2003? I can do an IF with no problem, but I need to test a field to
see if it meets about a dozen criteria, and it freaks out if I nest
more than 5 IF statements.

I've looked this up and found a few folks doing this in VB Script, but
given I've never done VBS in Excel, I don't even know where to begin
on that front if that's the only way.

Thanks in advance for any suggestions --

Alex
 
Reply With Quote
 
 
 
 
Gary''s Student
Guest
Posts: n/a
 
      3rd Apr 2008
Sub routine()
v = ActiveCell.Value
Select Case v
Case "dog"
MsgBox ("a mammal")
Case "rose"
MsgBox ("a flower")
Case "guppy"
MsgBox ("a fish")
End Select
End Sub

--
Gary''s Student - gsnu2007g


"Alex" wrote:

> Stupid question, but is it possible to do a Case statement in Excel
> 2003? I can do an IF with no problem, but I need to test a field to
> see if it meets about a dozen criteria, and it freaks out if I nest
> more than 5 IF statements.
>
> I've looked this up and found a few folks doing this in VB Script, but
> given I've never done VBS in Excel, I don't even know where to begin
> on that front if that's the only way.
>
> Thanks in advance for any suggestions --
>
> Alex
>

 
Reply With Quote
 
Alex
Guest
Posts: n/a
 
      3rd Apr 2008
On Apr 3, 11:49*am, Gary''s Student
<GarysStud...@discussions.microsoft.com> wrote:
> Sub routine()
> v = ActiveCell.Value
> Select Case v
> Case "dog"
> * * MsgBox ("a mammal")
> Case "rose"
> * * MsgBox ("a flower")
> Case "guppy"
> * * MsgBox ("a fish")
> End Select
> End Sub
>
> --
> Gary''s Student - gsnu2007g
>
>

Hi Gary,

Thanks for the reply, but this doesn't help much. Where would I plug
this or similar code into a spreadsheet to execute?

Thanks again - Alex
 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      3rd Apr 2008
Maybe you could put your list of criteria in a column in a different worksheet
and whatever you want associated with each value in the adjacent cell. I'd use
A1:B12 (about).

Then I could use =vlookup() to retrieve that associated value.

Debra Dalgleish has lots of notes on =vlookup():
http://www.contextures.com/xlFunctions02.html (for =vlookup())

Alex wrote:
>
> Stupid question, but is it possible to do a Case statement in Excel
> 2003? I can do an IF with no problem, but I need to test a field to
> see if it meets about a dozen criteria, and it freaks out if I nest
> more than 5 IF statements.
>
> I've looked this up and found a few folks doing this in VB Script, but
> given I've never done VBS in Excel, I don't even know where to begin
> on that front if that's the only way.
>
> Thanks in advance for any suggestions --
>
> Alex


--

Dave Peterson
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with Excel 2003 (multiple IF statements) Steve Chalom Microsoft Excel Worksheet Functions 5 3rd Nov 2009 03:55 PM
Using Case statements Charess Microsoft Access Getting Started 10 14th Sep 2009 10:04 PM
Nesting more than 7 IF statements (Excel 2003) Dee Microsoft Excel Worksheet Functions 7 20th Aug 2009 02:05 PM
Solver statements XLM ---> Excel 2003 programmernovice@yahoo.com Microsoft Excel Programming 0 13th Jul 2006 05:09 PM
If statements (of course) {running excel 2003} jacob Microsoft Excel Misc 4 4th Aug 2005 09:51 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:31 AM.