+ Reply to Thread
Results 1 to 3 of 3

Macro for Case Sensitive Text Search

Hybrid View

vcs1161 Macro for Case Sensitive Text... 04-23-2013, 10:11 AM
AB33 Re: Macro for Case Sensitive... 04-23-2013, 10:59 AM
vcs1161 Re: Macro for Case Sensitive... 04-23-2013, 11:13 AM
  1. #1
    Registered User
    Join Date
    12-13-2012
    Location
    Minnesota
    MS-Off Ver
    Excel 2010
    Posts
    40

    Question Macro for Case Sensitive Text Search

    This macro is working well but I have come across a snag where there may be times when a keyword must be case sensitive. For example one keyword is BAC but it is picking up simple words like back and such. This is the code I am using but not sure where and how to incorporate the case sensitive piece. Do I use an Exact or UCase function somewhere?

    Sub UserInputSearch()
    Dim r As Range, LastRow As Long
    Dim rs As Range
     Dim v As Variant, s As String
     Dim TextEntry As String
     Dim Msg As String
     Dim Entry As String
     Dim x As Long, where As Long
     Dim Rng As Range
     Dim CellCount As String
     
     Set rs = Application.InputBox(Prompt:="Select the Column for Lookup", Title:="Range Select", Type:=8)
     rs.Name = "Lookup"
    
     Msg = "Separate Each Keyword with a Comma (ex. brain,seizure)"
     TextEntry = InputBox(Msg)
     
    LastRow = Cells(Cells.Rows.Count, "A").End(xlUp).Row
    Entry = TextEntry
    v = Split(Entry, ",")
    For Each r In Range("Lookup")
         For x = 0 To UBound(v)
             If InStr(1, r.Value, v(x), vbTextCompare) > 0 Then
             where = InStr(1, r.Value, v(x), vbTextCompare)
             With r
                 .Characters(Start:=where, Length:=Len(v(x))).Font.FontStyle = "Bold"
                 .Characters(Start:=where, Length:=Len(v(x))).Font.ColorIndex = 3
             End With
             End If
         
        Next
     Next r
         Range("A1").Select
         Exit Sub
    
    End Sub

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Macro for Case Sensitive Text Search

     If InStr(r.Value, v(x)) > 0 Then

  3. #3
    Registered User
    Join Date
    12-13-2012
    Location
    Minnesota
    MS-Off Ver
    Excel 2010
    Posts
    40

    Re: Macro for Case Sensitive Text Search

    Thank you so much! I believe that did the trick.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1