Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
jeffP
 
Posts: n/a
Default Case Sensitive w/ IF

All I'm trying to do is check a cell for a text answer:

If ActiveCell.Text = "Yes" Then

but I need to test for YES,YEs,Yes,and yes

Do I really need to nest four If statements to do that?

Thanks for any and all help

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Ian
 
Posts: n/a
Default Case Sensitive w/ IF

If Ucase(ActiveCell.Text) = "YES" Then

This checks whether the text in the active cell matches, when changed to
upper case.

--
Ian
--
"jeffP" wrote in message
...
All I'm trying to do is check a cell for a text answer:

If ActiveCell.Text = "Yes" Then

but I need to test for YES,YEs,Yes,and yes

Do I really need to nest four If statements to do that?

Thanks for any and all help



  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Dave Peterson
 
Posts: n/a
Default Case Sensitive w/ IF

One way:
if lcase(activecell.text)="yes" then

Another:
if strcomp(activecell.text, "yes", vbtextcompare) = 0 then

or put
Option Compare Text
at the top of the module


jeffP wrote:

All I'm trying to do is check a cell for a text answer:

If ActiveCell.Text = "Yes" Then

but I need to test for YES,YEs,Yes,and yes

Do I really need to nest four If statements to do that?

Thanks for any and all help


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Ron Rosenfeld
 
Posts: n/a
Default Case Sensitive w/ IF

On Sun, 5 Feb 2006 10:26:28 -0800, "jeffP"
wrote:

All I'm trying to do is check a cell for a text answer:

If ActiveCell.Text = "Yes" Then

but I need to test for YES,YEs,Yes,and yes

Do I really need to nest four If statements to do that?

Thanks for any and all help


Do something like:

If Ucase(ActiveCell.Text)= "Yes" Then


--ron
  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Biff
 
Posts: n/a
Default Case Sensitive w/ IF

Hi!

Try this:

=OR(EXACT(A1,{"YES","YEs","Yes","yes"}))

Biff

"jeffP" wrote in message
...
All I'm trying to do is check a cell for a text answer:

If ActiveCell.Text = "Yes" Then

but I need to test for YES,YEs,Yes,and yes

Do I really need to nest four If statements to do that?

Thanks for any and all help





  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Bernard Liengme
 
Posts: n/a
Default Case Sensitive w/ IF

I experimented with

Sub what()
If UCase(ActiveCell.Text) = "YES" Then
Range("D1") = "OK"
Else
Range("D1") = "No"
End If
End Sub

and found <If UCase(ActiveCell.Text) = "YES".... does what you want
--
Bernard V Liengme
www.stfx.ca/people/bliengme
remove caps from email

"jeffP" wrote in message
...
All I'm trying to do is check a cell for a text answer:

If ActiveCell.Text = "Yes" Then

but I need to test for YES,YEs,Yes,and yes

Do I really need to nest four If statements to do that?

Thanks for any and all help



  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
jeffP
 
Posts: n/a
Default Case Sensitive w/ IF

Thanks to all for the quick and good answers.
Always interested in learing so Dave could you explain further the Option
Compare Text?

thanks again

"Dave Peterson" wrote:

One way:
if lcase(activecell.text)="yes" then

Another:
if strcomp(activecell.text, "yes", vbtextcompare) = 0 then

or put
Option Compare Text
at the top of the module


jeffP wrote:

All I'm trying to do is check a cell for a text answer:

If ActiveCell.Text = "Yes" Then

but I need to test for YES,YEs,Yes,and yes

Do I really need to nest four If statements to do that?

Thanks for any and all help


--

Dave Peterson

  #8   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Dave Peterson
 
Posts: n/a
Default Case Sensitive w/ IF

You can tell excel to ignore case in text comparisons for that module.

Just put that "option compare text" at the top of the module.

Put it at the top of a test module.
select Option and hit F1. You'll see VBA's help for all the Option options.

jeffP wrote:

Thanks to all for the quick and good answers.
Always interested in learing so Dave could you explain further the Option
Compare Text?

thanks again

"Dave Peterson" wrote:

One way:
if lcase(activecell.text)="yes" then

Another:
if strcomp(activecell.text, "yes", vbtextcompare) = 0 then

or put
Option Compare Text
at the top of the module


jeffP wrote:

All I'm trying to do is check a cell for a text answer:

If ActiveCell.Text = "Yes" Then

but I need to test for YES,YEs,Yes,and yes

Do I really need to nest four If statements to do that?

Thanks for any and all help


--

Dave Peterson


--

Dave Peterson
  #9   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Dave Peterson
 
Posts: n/a
Default Case Sensitive w/ IF

Just a typo alert...

I bet Ron meant YES in:
If Ucase(ActiveCell.Text)= "Yes" Then



Ron Rosenfeld wrote:

On Sun, 5 Feb 2006 10:26:28 -0800, "jeffP"
wrote:

All I'm trying to do is check a cell for a text answer:

If ActiveCell.Text = "Yes" Then

but I need to test for YES,YEs,Yes,and yes

Do I really need to nest four If statements to do that?

Thanks for any and all help


Do something like:

If Ucase(ActiveCell.Text)= "Yes" Then

--ron


--

Dave Peterson
  #10   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Ron Rosenfeld
 
Posts: n/a
Default Case Sensitive w/ IF

On Sun, 05 Feb 2006 14:06:10 -0600, Dave Peterson
wrote:

Just a typo alert...

I bet Ron meant YES in:
If Ucase(ActiveCell.Text)= "Yes" Then



"Typos 'R Us"!!
Thanks



--ron


  #11   Report Post  
Posted to microsoft.public.excel.worksheet.functions
jeffP
 
Posts: n/a
Default Case Sensitive w/ IF

Dave,
I tried this originally 'cause it seemed so simple for my small routine BUT
I put it inside the procedure and of course got error ....
the strcomp works just fine also

Thanks as always


"Dave Peterson" wrote:

You can tell excel to ignore case in text comparisons for that module.

Just put that "option compare text" at the top of the module.

Put it at the top of a test module.
select Option and hit F1. You'll see VBA's help for all the Option options.

jeffP wrote:

Thanks to all for the quick and good answers.
Always interested in learing so Dave could you explain further the Option
Compare Text?

thanks again

"Dave Peterson" wrote:

One way:
if lcase(activecell.text)="yes" then

Another:
if strcomp(activecell.text, "yes", vbtextcompare) = 0 then

or put
Option Compare Text
at the top of the module


jeffP wrote:

All I'm trying to do is check a cell for a text answer:

If ActiveCell.Text = "Yes" Then

but I need to test for YES,YEs,Yes,and yes

Do I really need to nest four If statements to do that?

Thanks for any and all help

--

Dave Peterson


--

Dave Peterson

  #12   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Dave Peterson
 
Posts: n/a
Default Case Sensitive w/ IF

I'm kind of confused. Does this mean that after you moved that
"Option compare text" to the very top of the module that you got your code to
work ok (with no change)?



jeffP wrote:

Dave,
I tried this originally 'cause it seemed so simple for my small routine BUT
I put it inside the procedure and of course got error ....
the strcomp works just fine also

Thanks as always

"Dave Peterson" wrote:

You can tell excel to ignore case in text comparisons for that module.

Just put that "option compare text" at the top of the module.

Put it at the top of a test module.
select Option and hit F1. You'll see VBA's help for all the Option options.

jeffP wrote:

Thanks to all for the quick and good answers.
Always interested in learing so Dave could you explain further the Option
Compare Text?

thanks again

"Dave Peterson" wrote:

One way:
if lcase(activecell.text)="yes" then

Another:
if strcomp(activecell.text, "yes", vbtextcompare) = 0 then

or put
Option Compare Text
at the top of the module


jeffP wrote:

All I'm trying to do is check a cell for a text answer:

If ActiveCell.Text = "Yes" Then

but I need to test for YES,YEs,Yes,and yes

Do I really need to nest four If statements to do that?

Thanks for any and all help

--

Dave Peterson


--

Dave Peterson


--

Dave Peterson
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
I NEED HELP with the SPELLNUMBER Function vag Excel Worksheet Functions 0 June 21st 05 08:17 AM
EXCEL:NUMBER TO GREEK WORDS vag Excel Worksheet Functions 1 June 15th 05 05:57 PM
convert value in word. For Exampe Rs.115.00 convert into word as . Shakti Excel Discussion (Misc queries) 1 May 10th 05 12:00 PM
Conversion SVC Excel Worksheet Functions 9 February 28th 05 02:29 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 05:33 AM.

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

About Us

"It's about Microsoft Excel"