Link to home
Start Free TrialLog in
Avatar of shaneleach
shaneleachFlag for United States of America

asked on

Make VB Case Insensitive

I am trying to alter a macro to make it case insensitive.  It is used within an Excel template for a report one of our coders (medical, not computer) uses to post procedures from.  I just discovered today that the entity sending the file isn't always consistent in the procedure name (sometimes it's lower case or mixed).  How is this accomplished using the attached macro/code?  Thanks!!!
Option Explicit
Sub KillRows()
 
Dim Trange As Range
 Dim Row As Range
 
For Each Row In ActiveSheet.UsedRange.EntireRow.Rows
    If Row.Cells(1, "F") = "CT-CA++SCORE" Then
        If Trange Is Nothing Then
            Set Trange = Row
        Else
            Set Trange = Union(Trange, Row)
        End If
    End If
    Next Row
    
    If Not Trange Is Nothing Then
    Trange.Delete Shift:=xlUp
End If
 
End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Makrini
Makrini
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of shaneleach

ASKER

Thank you Makrini!!!  I love EE!!!!  
Avatar of Altwies
Altwies

Simply use the Format Function:

dim s1 as string

s1 = Format("This is a test", ">")

s1 will be all upper case

do this prior to testing your string data for all opperands and you will get case  insensitive compares.
Avatar of GrahamSkan
In VBA (not VB6) you can put

Option Compare Text

at the top of the code module(s) so that you don't have to convert each string to one particular case.