PC Review


Reply
Thread Tools Rate Thread

can VB ignore capitalization

 
 
dawall33
Guest
Posts: n/a
 
      9th Apr 2009
When I compare cell a1 to b1 in a formula capitalization is ignored, (ie. 2a
= 2A). This same check in a VB script fails. I'm trying to create a sheet
based of a text box and my check against the names passes but I get an error
trying to name the new sheet with the capitalized version of the name.

Ideas?
 
Reply With Quote
 
 
 
 
Mike H
Guest
Posts: n/a
 
      9th Apr 2009
Hi,

Do an upper case compare

If UCase(Range("a1")) = UCase(Range("b1")) Then
'do things
End If

Mike

"dawall33" wrote:

> When I compare cell a1 to b1 in a formula capitalization is ignored, (ie. 2a
> = 2A). This same check in a VB script fails. I'm trying to create a sheet
> based of a text box and my check against the names passes but I get an error
> trying to name the new sheet with the capitalized version of the name.
>
> Ideas?

 
Reply With Quote
 
Mike H
Guest
Posts: n/a
 
      9th Apr 2009
Hi,

Similar solution

Private Sub Worksheet_Change(ByVal Target As Range)
If Range("A1").Value = 99 Then
Range("B1").Hyperlinks(1).Follow
End If
End Sub


Mike

"Mike H" wrote:

> Hi,
>
> Do an upper case compare
>
> If UCase(Range("a1")) = UCase(Range("b1")) Then
> 'do things
> End If
>
> Mike
>
> "dawall33" wrote:
>
> > When I compare cell a1 to b1 in a formula capitalization is ignored, (ie. 2a
> > = 2A). This same check in a VB script fails. I'm trying to create a sheet
> > based of a text box and my check against the names passes but I get an error
> > trying to name the new sheet with the capitalized version of the name.
> >
> > Ideas?

 
Reply With Quote
 
Mike H
Guest
Posts: n/a
 
      9th Apr 2009
OOPS wrong thread

"Mike H" wrote:

> Hi,
>
> Similar solution
>
> Private Sub Worksheet_Change(ByVal Target As Range)
> If Range("A1").Value = 99 Then
> Range("B1").Hyperlinks(1).Follow
> End If
> End Sub
>
>
> Mike
>
> "Mike H" wrote:
>
> > Hi,
> >
> > Do an upper case compare
> >
> > If UCase(Range("a1")) = UCase(Range("b1")) Then
> > 'do things
> > End If
> >
> > Mike
> >
> > "dawall33" wrote:
> >
> > > When I compare cell a1 to b1 in a formula capitalization is ignored, (ie. 2a
> > > = 2A). This same check in a VB script fails. I'm trying to create a sheet
> > > based of a text box and my check against the names passes but I get an error
> > > trying to name the new sheet with the capitalized version of the name.
> > >
> > > Ideas?

 
Reply With Quote
 
Jim Cone
Guest
Posts: n/a
 
      9th Apr 2009
Re: Ideas?

Patient: "Doctor, it hurts when I do this"
Doctor: "Don't do that.
--
Jim Cone
Portland, Oregon USA



"dawall33" <(E-Mail Removed)>
wrote in message
When I compare cell a1 to b1 in a formula capitalization is ignored, (ie. 2a
= 2A). This same check in a VB script fails. I'm trying to create a sheet
based of a text box and my check against the names passes but I get an error
trying to name the new sheet with the capitalized version of the name.

Ideas?
 
Reply With Quote
 
Mike H
Guest
Posts: n/a
 
      9th Apr 2009
Hi,

No problem we'll get there. using X in your code makes X a variable and not
the letter X. To make it the letter X put it in quotes like below. Now you
'may' encounter another problem because it becomes case sensitive so note how
i've included an UCASE statement so if you now enter x or X it works

Private Sub Worksheet_Change(ByVal Target As Range)
If UCase(Range("E5").Value) = "X" Then
Range("B5").Hyperlinks(1).Follow
End If
End Sub

Mike



"Mike H" wrote:

> OOPS wrong thread
>
> "Mike H" wrote:
>
> > Hi,
> >
> > Similar solution
> >
> > Private Sub Worksheet_Change(ByVal Target As Range)
> > If Range("A1").Value = 99 Then
> > Range("B1").Hyperlinks(1).Follow
> > End If
> > End Sub
> >
> >
> > Mike
> >
> > "Mike H" wrote:
> >
> > > Hi,
> > >
> > > Do an upper case compare
> > >
> > > If UCase(Range("a1")) = UCase(Range("b1")) Then
> > > 'do things
> > > End If
> > >
> > > Mike
> > >
> > > "dawall33" wrote:
> > >
> > > > When I compare cell a1 to b1 in a formula capitalization is ignored, (ie. 2a
> > > > = 2A). This same check in a VB script fails. I'm trying to create a sheet
> > > > based of a text box and my check against the names passes but I get an error
> > > > trying to name the new sheet with the capitalized version of the name.
> > > >
> > > > Ideas?

 
Reply With Quote
 
Chip Pearson
Guest
Posts: n/a
 
      9th Apr 2009
You can make all text comparisons in a module ignore case by placing

Option Compare Text

at the top of the module (above and outside of any procedure or
variable declarations). Or, you can ignore case with StrComp

If StrComp(string1, string2, vbTextCompare) = 0 Then
' strings are equal
Else
' strings are different
End If

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)



On Thu, 9 Apr 2009 12:33:02 -0700, dawall33
<(E-Mail Removed)> wrote:

>When I compare cell a1 to b1 in a formula capitalization is ignored, (ie. 2a
>= 2A). This same check in a VB script fails. I'm trying to create a sheet
>based of a text box and my check against the names passes but I get an error
>trying to name the new sheet with the capitalized version of the name.
>
>Ideas?

 
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
Capitalization Mike H. Microsoft Excel Misc 1 21st May 2010 04:45 PM
Feedback: Ignore should mean ignore. Dan Spyware Discussion 1 27th Sep 2005 05:19 PM
Ignore means Ignore... ChriRobe Spyware Discussion 0 4th Feb 2005 07:37 AM
capitalization Trina Microsoft Excel Misc 3 11th Oct 2003 06:32 AM
Capitalization Robb Microsoft Word Document Management 0 14th Aug 2003 08:42 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:28 PM.