Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 553
Default Ignore Case without using Regular Expressions

Can I compare two text strings and ignore case without using Regular
Expressions? Is there a regular VBA text function I can use?

If IgnoreCase(Array1(0)) = IgnoreCase(Array2(0)) then
'Do something

End if

Thanks

EM
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 806
Default Ignore Case without using Regular Expressions

If UCase(Array1(0)) = UCase(Array2(0)) then

or

If LCase(Array1(0)) = LCase(Array2(0)) then

Regards,
Bernd
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Ignore Case without using Regular Expressions

You can use lcase():
if lcase(array1(0)) = lcase(array2(0)) then
or use ucase()

Or you could use
if strcomp(array1(0),array2(0),vbTextCompare) = 0 then

Or you could force every string comparison to be case-insensitive by adding a
line to the top of the module:

Option Compare Text



ExcelMonkey wrote:

Can I compare two text strings and ignore case without using Regular
Expressions? Is there a regular VBA text function I can use?

If IgnoreCase(Array1(0)) = IgnoreCase(Array2(0)) then
'Do something

End if

Thanks

EM


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Ignore Case without using Regular Expressions


Use the StrComp function and specify text (case insensitive)
comparison:

If StrComp(Array1(0), Array2(0), vbTextCompare) = 0 Then
' equal
Else
' not equal
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 Mon, 25 May 2009 14:28:01 -0700, ExcelMonkey
wrote:

Can I compare two text strings and ignore case without using Regular
Expressions? Is there a regular VBA text function I can use?

If IgnoreCase(Array1(0)) = IgnoreCase(Array2(0)) then
'Do something

End if

Thanks

EM

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 553
Default Ignore Case without using Regular Expressions

Thank-you!

EM

"Dave Peterson" wrote:

You can use lcase():
if lcase(array1(0)) = lcase(array2(0)) then
or use ucase()

Or you could use
if strcomp(array1(0),array2(0),vbTextCompare) = 0 then

Or you could force every string comparison to be case-insensitive by adding a
line to the top of the module:

Option Compare Text



ExcelMonkey wrote:

Can I compare two text strings and ignore case without using Regular
Expressions? Is there a regular VBA text function I can use?

If IgnoreCase(Array1(0)) = IgnoreCase(Array2(0)) then
'Do something

End if

Thanks

EM


--

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
Get rid of with regular expressions Howdy Excel Discussion (Misc queries) 1 January 18th 10 07:42 PM
Regular expressions Dave Excel Programming 5 September 20th 07 02:46 PM
Using Regular Expressions with VBA Andrew Hall NZ Excel Programming 5 November 21st 06 09:30 PM
Regular expressions JeffMelton Excel Programming 2 March 1st 06 12:52 AM
Regular Expressions in VBA? Rob[_23_] Excel Programming 13 February 10th 05 05:34 AM


All times are GMT +1. The time now is 12:36 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"