PC Review


Reply
Thread Tools Rate Thread

Case sensitivity

 
 
JohnL
Guest
Posts: n/a
 
      29th Mar 2009
I have created a Private Sub Worksheet_Change(ByVal Target As Range), with a
Select Case argument. When the value of cell D6 is equal to “HOUSE”, then
the interior color of cell A8 becomes yellow.
But if the user enters “House” in cell D6, then it doesn’t work. How can I
overcome case sensitivity?

TIA

JohnL

 
Reply With Quote
 
 
 
 
Rick Rothstein
Guest
Posts: n/a
 
      29th Mar 2009
It is always a good idea to show the code you are using for the problem area
you are asking your question about. My guess is for you to use the UCase
function on the argument to the Select Case statement and then test the
individual Case statements against upper case text. For example...

Select Case UCase(Target.Value)
Case "HOUSE"
....
Case "ROOM"
....
etc.
End Select

--
Rick (MVP - Excel)


"JohnL" <(E-Mail Removed)> wrote in message
news:3D842859-A202-4FB1-9719-(E-Mail Removed)...
>I have created a Private Sub Worksheet_Change(ByVal Target As Range), with
>a
> Select Case argument. When the value of cell D6 is equal to “HOUSE”, then
> the interior color of cell A8 becomes yellow.
> But if the user enters “House” in cell D6, then it doesn’t work. How can
> I
> overcome case sensitivity?
>
> TIA
>
> JohnL
>


 
Reply With Quote
 
JohnL
Guest
Posts: n/a
 
      29th Mar 2009
Rick, what it looks looks like is this:

Select Case Range("D6").Value

Case "HOUSE"
Range("A8”).Interior.ColorIndex = 6
Range("A8").Font.ColorIndex = 2


"Rick Rothstein" wrote:

> It is always a good idea to show the code you are using for the problem area
> you are asking your question about. My guess is for you to use the UCase
> function on the argument to the Select Case statement and then test the
> individual Case statements against upper case text. For example...
>
> Select Case UCase(Target.Value)
> Case "HOUSE"
> ....
> Case "ROOM"
> ....
> etc.
> End Select
>
> --
> Rick (MVP - Excel)
>


 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      29th Mar 2009
Notice Rick's suggestion included ucase().

Select Case UCase(Target.Value)

So you could use:

Select Case ucase(Range("D6").Value)

Another alternative if you don't care about any case comparisons...

Add this line to the top of the module:

Option Compare Text



JohnL wrote:
>
> Rick, what it looks looks like is this:
>
> Select Case Range("D6").Value
>
> Case "HOUSE"
> Range("A8”).Interior.ColorIndex = 6
> Range("A8").Font.ColorIndex = 2
>
> "Rick Rothstein" wrote:
>
> > It is always a good idea to show the code you are using for the problem area
> > you are asking your question about. My guess is for you to use the UCase
> > function on the argument to the Select Case statement and then test the
> > individual Case statements against upper case text. For example...
> >
> > Select Case UCase(Target.Value)
> > Case "HOUSE"
> > ....
> > Case "ROOM"
> > ....
> > etc.
> > End Select
> >
> > --
> > Rick (MVP - Excel)
> >


--

Dave Peterson
 
Reply With Quote
 
JohnL
Guest
Posts: n/a
 
      29th Mar 2009
Thanks Dave. I was confused with (Target.Value) but your line was very
explanatory. My Worksheet Sub works like a charm now. Couldn't use your
second suggestion because this isn't in a module.
Thanks Rick and Dave for your time. I always learn things at this site.
JohnL

"Dave Peterson" wrote:

> Notice Rick's suggestion included ucase().
>
> Select Case UCase(Target.Value)
>
> So you could use:
>
> Select Case ucase(Range("D6").Value)
>
> Another alternative if you don't care about any case comparisons...
>
> Add this line to the top of the module:
>
> Option Compare Text
>
>
>
> JohnL wrote:
> >
> > Rick, what it looks looks like is this:
> >
> > Select Case Range("D6").Value
> >
> > Case "HOUSE"
> > Range("A8”).Interior.ColorIndex = 6
> > Range("A8").Font.ColorIndex = 2
> >
> > "Rick Rothstein" wrote:
> >
> > > It is always a good idea to show the code you are using for the problem area
> > > you are asking your question about. My guess is for you to use the UCase
> > > function on the argument to the Select Case statement and then test the
> > > individual Case statements against upper case text. For example...
> > >
> > > Select Case UCase(Target.Value)
> > > Case "HOUSE"
> > > ....
> > > Case "ROOM"
> > > ....
> > > etc.
> > > End Select
> > >
> > > --
> > > Rick (MVP - Excel)
> > >

>
> --
>
> Dave Peterson
>

 
Reply With Quote
 
Rick Rothstein
Guest
Posts: n/a
 
      30th Mar 2009
I used Target.Value for two reasons... one, you showed you were using a
Change event procedure and so I guessed you were working with the Target
argument that the procedure automatically references and, two, you didn't
post your code originally so I didn't know what you were using for the
argument to the Select Case statement. As I said originally, "It is always a
good idea to show the code you are using for the problem area you are asking
your question about" and the reason is because we can tailor our response to
it and you won't be left scratching your head as to how to change our
solutions based on a guessed-at condition.

--
Rick (MVP - Excel)


"JohnL" <(E-Mail Removed)> wrote in message
news:A58EEC7B-FAE4-4AE5-8C3A-(E-Mail Removed)...
> Thanks Dave. I was confused with (Target.Value) but your line was very
> explanatory. My Worksheet Sub works like a charm now. Couldn't use your
> second suggestion because this isn't in a module.
> Thanks Rick and Dave for your time. I always learn things at this site.
> JohnL
>
> "Dave Peterson" wrote:
>
>> Notice Rick's suggestion included ucase().
>>
>> Select Case UCase(Target.Value)
>>
>> So you could use:
>>
>> Select Case ucase(Range("D6").Value)
>>
>> Another alternative if you don't care about any case comparisons...
>>
>> Add this line to the top of the module:
>>
>> Option Compare Text
>>
>>
>>
>> JohnL wrote:
>> >
>> > Rick, what it looks looks like is this:
>> >
>> > Select Case Range("D6").Value
>> >
>> > Case "HOUSE"
>> > Range("A8”).Interior.ColorIndex = 6
>> > Range("A8").Font.ColorIndex = 2
>> >
>> > "Rick Rothstein" wrote:
>> >
>> > > It is always a good idea to show the code you are using for the
>> > > problem area
>> > > you are asking your question about. My guess is for you to use the
>> > > UCase
>> > > function on the argument to the Select Case statement and then test
>> > > the
>> > > individual Case statements against upper case text. For example...
>> > >
>> > > Select Case UCase(Target.Value)
>> > > Case "HOUSE"
>> > > ....
>> > > Case "ROOM"
>> > > ....
>> > > etc.
>> > > End Select
>> > >
>> > > --
>> > > Rick (MVP - Excel)
>> > >

>>
>> --
>>
>> Dave Peterson
>>


 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      30th Mar 2009
It's in a worksheet module.

The "option compare text" will work in that kind of module, too.

JohnL wrote:
>
> Thanks Dave. I was confused with (Target.Value) but your line was very
> explanatory. My Worksheet Sub works like a charm now. Couldn't use your
> second suggestion because this isn't in a module.
> Thanks Rick and Dave for your time. I always learn things at this site.
> JohnL
>
> "Dave Peterson" wrote:
>
> > Notice Rick's suggestion included ucase().
> >
> > Select Case UCase(Target.Value)
> >
> > So you could use:
> >
> > Select Case ucase(Range("D6").Value)
> >
> > Another alternative if you don't care about any case comparisons...
> >
> > Add this line to the top of the module:
> >
> > Option Compare Text
> >
> >
> >
> > JohnL wrote:
> > >
> > > Rick, what it looks looks like is this:
> > >
> > > Select Case Range("D6").Value
> > >
> > > Case "HOUSE"
> > > Range("A8”).Interior.ColorIndex = 6
> > > Range("A8").Font.ColorIndex = 2
> > >
> > > "Rick Rothstein" wrote:
> > >
> > > > It is always a good idea to show the code you are using for the problem area
> > > > you are asking your question about. My guess is for you to use the UCase
> > > > function on the argument to the Select Case statement and then test the
> > > > individual Case statements against upper case text. For example...
> > > >
> > > > Select Case UCase(Target.Value)
> > > > Case "HOUSE"
> > > > ....
> > > > Case "ROOM"
> > > > ....
> > > > etc.
> > > > End Select
> > > >
> > > > --
> > > > Rick (MVP - Excel)
> > > >

> >
> > --
> >
> > Dave Peterson
> >


--

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
Re: case sensitivity Cor Ligthert [MVP] Microsoft VB .NET 0 30th Aug 2005 03:11 PM
C# case sensitivity and VS. Microsoft C# .NET 4 2nd Apr 2004 10:39 PM
case sensitivity Jeff S Microsoft C# .NET 5 6th Dec 2003 12:58 AM
Case sensitivity bigbob Microsoft C# .NET 6 4th Sep 2003 07:03 AM
C# Case sensitivity? Ben Microsoft Dot NET 0 1st Aug 2003 04:44 PM


Features
 

Advertising
 

Newsgroups
 


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