All I'm trying to do is check a cell for a text answer:
If ActiveCell.Text = quot;Yesquot; 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 helpIf Ucase(ActiveCell.Text) = quot;YESquot; Then
This checks whether the text in the active cell matches, when changed to
upper case.
--
Ian
--
quot;jeffPquot; gt; wrote in message
...
gt; All I'm trying to do is check a cell for a text answer:
gt;
gt; If ActiveCell.Text = quot;Yesquot; Then
gt;
gt; but I need to test for YES,YEs,Yes,and yes
gt;
gt; Do I really need to nest four If statements to do that?
gt;
gt; Thanks for any and all help
gt;
One way:
if lcase(activecell.text)=quot;yesquot; then
Another:
if strcomp(activecell.text, quot;yesquot;, vbtextcompare) = 0 then
or put
Option Compare Text
at the top of the modulejeffP wrote:
gt;
gt; All I'm trying to do is check a cell for a text answer:
gt;
gt; If ActiveCell.Text = quot;Yesquot; Then
gt;
gt; but I need to test for YES,YEs,Yes,and yes
gt;
gt; Do I really need to nest four If statements to do that?
gt;
gt; Thanks for any and all help
--
Dave Peterson
On Sun, 5 Feb 2006 10:26:28 -0800, quot;jeffPquot; gt;
wrote:
gt;All I'm trying to do is check a cell for a text answer:
gt;
gt;If ActiveCell.Text = quot;Yesquot; Then
gt;
gt;but I need to test for YES,YEs,Yes,and yes
gt;
gt;Do I really need to nest four If statements to do that?
gt;
gt;Thanks for any and all help
Do something like:
If Ucase(ActiveCell.Text)= quot;Yesquot; Then--ron
Hi!
Try this:
=OR(EXACT(A1,{quot;YESquot;,quot;YEsquot;,quot;Yesquot;,quot;yesquot;}))
Biff
quot;jeffPquot; gt; wrote in message
...
gt; All I'm trying to do is check a cell for a text answer:
gt;
gt; If ActiveCell.Text = quot;Yesquot; Then
gt;
gt; but I need to test for YES,YEs,Yes,and yes
gt;
gt; Do I really need to nest four If statements to do that?
gt;
gt; Thanks for any and all help
gt;
I experimented with
Sub what()
If UCase(ActiveCell.Text) = quot;YESquot; Then
Range(quot;D1quot;) = quot;OKquot;
Else
Range(quot;D1quot;) = quot;Noquot;
End If
End Sub
and found lt;If UCase(ActiveCell.Text) = quot;YESquot;....gt; does what you want
--
Bernard V Liengme
www.stfx.ca/people/bliengme
remove caps from email
quot;jeffPquot; gt; wrote in message
...
gt; All I'm trying to do is check a cell for a text answer:
gt;
gt; If ActiveCell.Text = quot;Yesquot; Then
gt;
gt; but I need to test for YES,YEs,Yes,and yes
gt;
gt; Do I really need to nest four If statements to do that?
gt;
gt; Thanks for any and all help
gt;
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
quot;Dave Petersonquot; wrote:
gt; One way:
gt; if lcase(activecell.text)=quot;yesquot; then
gt;
gt; Another:
gt; if strcomp(activecell.text, quot;yesquot;, vbtextcompare) = 0 then
gt;
gt; or put
gt; Option Compare Text
gt; at the top of the module
gt;
gt;
gt; jeffP wrote:
gt; gt;
gt; gt; All I'm trying to do is check a cell for a text answer:
gt; gt;
gt; gt; If ActiveCell.Text = quot;Yesquot; Then
gt; gt;
gt; gt; but I need to test for YES,YEs,Yes,and yes
gt; gt;
gt; gt; Do I really need to nest four If statements to do that?
gt; gt;
gt; gt; Thanks for any and all help
gt;
gt; --
gt;
gt; Dave Peterson
gt;
You can tell excel to ignore case in text comparisons for that module.
Just put that quot;option compare textquot; 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:
gt;
gt; Thanks to all for the quick and good answers.
gt; Always interested in learing so Dave could you explain further the Option
gt; Compare Text?
gt;
gt; thanks again
gt;
gt; quot;Dave Petersonquot; wrote:
gt;
gt; gt; One way:
gt; gt; if lcase(activecell.text)=quot;yesquot; then
gt; gt;
gt; gt; Another:
gt; gt; if strcomp(activecell.text, quot;yesquot;, vbtextcompare) = 0 then
gt; gt;
gt; gt; or put
gt; gt; Option Compare Text
gt; gt; at the top of the module
gt; gt;
gt; gt;
gt; gt; jeffP wrote:
gt; gt; gt;
gt; gt; gt; All I'm trying to do is check a cell for a text answer:
gt; gt; gt;
gt; gt; gt; If ActiveCell.Text = quot;Yesquot; Then
gt; gt; gt;
gt; gt; gt; but I need to test for YES,YEs,Yes,and yes
gt; gt; gt;
gt; gt; gt; Do I really need to nest four If statements to do that?
gt; gt; gt;
gt; gt; gt; Thanks for any and all help
gt; gt;
gt; gt; --
gt; gt;
gt; gt; Dave Peterson
gt; gt;
--
Dave Peterson
Just a typo alert...
I bet Ron meant YES in:
If Ucase(ActiveCell.Text)= quot;Yesquot; Then
Ron Rosenfeld wrote:
gt;
gt; On Sun, 5 Feb 2006 10:26:28 -0800, quot;jeffPquot; gt;
gt; wrote:
gt;
gt; gt;All I'm trying to do is check a cell for a text answer:
gt; gt;
gt; gt;If ActiveCell.Text = quot;Yesquot; Then
gt; gt;
gt; gt;but I need to test for YES,YEs,Yes,and yes
gt; gt;
gt; gt;Do I really need to nest four If statements to do that?
gt; gt;
gt; gt;Thanks for any and all help
gt;
gt; Do something like:
gt;
gt; If Ucase(ActiveCell.Text)= quot;Yesquot; Then
gt;
gt; --ron
--
Dave Peterson
On Sun, 05 Feb 2006 14:06:10 -0600, Dave Peterson gt;
wrote:
gt;Just a typo alert...
gt;
gt;I bet Ron meant YES in:
gt;If Ucase(ActiveCell.Text)= quot;Yesquot; Then
gt;
gt;
quot;Typos 'R Usquot;!!
Thanks
--ron
- Jul 25 Fri 2008 20:45
Case Sensitive w/ IF
close
全站熱搜
留言列表
發表留言
留言列表

