PC Review


Reply
Thread Tools Rate Thread

Case format for getting cell value from a worksheet.

 
 
George
Guest
Posts: n/a
 
      11th May 2010
Good Afternoon,

I need to create a series of Case conditions based on the value of a cell on
a certain worksheet in my open workbook..For the life of me I cannot get the
syntax right and I'd appreciate any help i could get.

My condition is on a worksheet named "Lookup_Values" Cell "M3" is a value
used as a case condition. what I want to do is retrive that value and use it
to compare against each case like below.

RPT_Date = ("Lookup_Values!M3")

Select Case True
Case RPT_Date = "January"
Perform my actrions
Exit Sub

Case RPT_Date = "Febuary"
Perform my actrions
Exit Sub
End Select

I appreciate any help in showing me the error of my ways, and again Thank
You in advance.

George

 
Reply With Quote
 
 
 
 
Mike H
Guest
Posts: n/a
 
      11th May 2010
Hi,

Try it this way bit be aware of some pitfalls. The 'test' is case sensitive.
I'm assuming you have the text value of January in M3, if it's a properly
formatted date then this won't work.

To avoid the case issue you could use
Select Case ucase(RPT_Date)

and in the case statements us JANUARY etc

RPT_Date = Sheets("Lookup_Values").Range("M3")
Select Case RPT_Date
Case Is = "January"
' Perform my actrions
Exit Sub
Case Is = "Febuary"
'Perform my actrions
Exit Sub
End Select
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"George" wrote:

> Good Afternoon,
>
> I need to create a series of Case conditions based on the value of a cell on
> a certain worksheet in my open workbook..For the life of me I cannot get the
> syntax right and I'd appreciate any help i could get.
>
> My condition is on a worksheet named "Lookup_Values" Cell "M3" is a value
> used as a case condition. what I want to do is retrive that value and use it
> to compare against each case like below.
>
> RPT_Date = ("Lookup_Values!M3")
>
> Select Case True
> Case RPT_Date = "January"
> Perform my actrions
> Exit Sub
>
> Case RPT_Date = "Febuary"
> Perform my actrions
> Exit Sub
> End Select
>
> I appreciate any help in showing me the error of my ways, and again Thank
> You in advance.
>
> George
>

 
Reply With Quote
 
Gary Brown
Guest
Posts: n/a
 
      11th May 2010
Select Case RPT_Date
Case "January"
Perform my actrions
Exit Sub

Case "Febuary"
Perform my actrions
Exit Sub
End Select
--
Hope this helps.
If it does, please click the Yes button.
Thanks in advance for your feedback.
Gary Brown



"George" wrote:

> Good Afternoon,
>
> I need to create a series of Case conditions based on the value of a cell on
> a certain worksheet in my open workbook..For the life of me I cannot get the
> syntax right and I'd appreciate any help i could get.
>
> My condition is on a worksheet named "Lookup_Values" Cell "M3" is a value
> used as a case condition. what I want to do is retrive that value and use it
> to compare against each case like below.
>
> RPT_Date = ("Lookup_Values!M3")
>
> Select Case True
> Case RPT_Date = "January"
> Perform my actrions
> Exit Sub
>
> Case RPT_Date = "Febuary"
> Perform my actrions
> Exit Sub
> End Select
>
> I appreciate any help in showing me the error of my ways, and again Thank
> You in advance.
>
> George
>

 
Reply With Quote
 
George
Guest
Posts: n/a
 
      12th May 2010
Hey Guys,

Thanks for the help worked great!!!

George
"Gary Brown" wrote:

> Select Case RPT_Date
> Case "January"
> Perform my actrions
> Exit Sub
>
> Case "Febuary"
> Perform my actrions
> Exit Sub
> End Select
> --
> Hope this helps.
> If it does, please click the Yes button.
> Thanks in advance for your feedback.
> Gary Brown
>
>
>
> "George" wrote:
>
> > Good Afternoon,
> >
> > I need to create a series of Case conditions based on the value of a cell on
> > a certain worksheet in my open workbook..For the life of me I cannot get the
> > syntax right and I'd appreciate any help i could get.
> >
> > My condition is on a worksheet named "Lookup_Values" Cell "M3" is a value
> > used as a case condition. what I want to do is retrive that value and use it
> > to compare against each case like below.
> >
> > RPT_Date = ("Lookup_Values!M3")
> >
> > Select Case True
> > Case RPT_Date = "January"
> > Perform my actrions
> > Exit Sub
> >
> > Case RPT_Date = "Febuary"
> > Perform my actrions
> > Exit Sub
> > End Select
> >
> > I appreciate any help in showing me the error of my ways, and again Thank
> > You in advance.
> >
> > George
> >

 
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
Case Statement Format for getting cell value from a worksheet George Microsoft Excel Misc 1 11th May 2010 09:22 PM
Format Cell - Only Upper Case Alpha characters LinLin Microsoft Excel Misc 3 20th Mar 2009 12:15 PM
Format cell to convert to Upper case widman Microsoft Excel Misc 4 3rd Jun 2008 08:29 PM
how do I format a cell to display its contents in Upper case? =?Utf-8?B?TWFyY00=?= Microsoft Excel Misc 1 8th Mar 2007 03:19 AM
Excel Format Cell - first letter upper case i8theburger Microsoft Excel Programming 9 19th Apr 2004 10:57 PM


Features
 

Advertising
 

Newsgroups
 


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