If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > Could someone enlighten me about "Option Compare Text"?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-24-07, 14:04
Elixia Anxata Elixia Anxata is offline
Registered User
 
Join Date: Jun 2007
Posts: 6
Lightbulb Could someone enlighten me about "Option Compare Text"?

I have this formatting macro that well deletes stuff, highlights a row based on certain arguments, etc. I know Option Compare Text makes a module case insensitive, I was wondering if this ability extends to the arguments for Nested Ifs & Cases w/in that module. Since I need to make the arguments case insensitive. Ex. If "Tax" = "TAX" = "tax", delete the entire row...
Reply With Quote
  #2 (permalink)  
Old 07-25-07, 14:11
norie norie is offline
Registered User
 
Join Date: Mar 2006
Posts: 163
Well I think the short answer is yes, that's the whole point of Option Compare Text.
Reply With Quote
  #3 (permalink)  
Old 08-03-07, 22:20
savbill savbill is offline
Registered User
 
Join Date: Feb 2004
Posts: 533
I have never used Option Compare Text for this purpose or any purpose. Using the text functions "uCase" or "lCase" are good way to avoid case problems when comparing text. Here's an example.

Code:
Public Sub checkRows()

nRow = 25

For i = nRow To 2 Step -1
    bMatch = (UCase(Cells(i, 1)) = UCase(Cells(i, 2)))
    If bMatch Then
        Rows(i).EntireRow.Delete
    End If
Next

End Sub
Notice in the example I used 'Step -1' argument of the 'For' Loop to work backwards through the range. This way when a row is deleted it is not necessary to re-define the range because the subsequent row numbers have changed when the row has been deleted.

Normally I would use a function or statement to assign the last row number of the used range to the variable 'nRow' however for this simple example I just assigned the variable a number.

It doesn't make a difference if LCase or UCase funtion is used. The purpose is to ensure values are compared without a difference in case.
__________________
~

Bill
Reply With Quote
  #4 (permalink)  
Old 08-06-07, 07:54
MikeTheBike MikeTheBike is offline
Registered User
 
Join Date: Apr 2004
Location: Derbyshire, UK
Posts: 714
Hi Bill

I tend to do exactly the same. The only time I've used Option Compare is when verifying passwords that are case sensitive.

MTB
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 On