Results 1 to 7 of 7

Thread: Highlighting All the Cells of Active sheet which contains a particular String:

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Member littleiitin's Avatar
    Join Date
    Aug 2011
    Posts
    90
    Rep Power
    15
    Thanks Admin,

    All Points accepted and incorporated.

    Your Find All function is Awesome.

    Thanks for All your Guidance.

    Regards
    Rahul

  2. #2
    Senior Member
    Join Date
    Apr 2011
    Posts
    190
    Rep Power
    15
    If you want all string comparisons to be case insensetive then use
    Code:
    Option Compare Text
    in the declaration section - so very top line of code.

    Now you can forget about upper/Lower case conflicts
    xl2007 - Windows 7
    xl hates the 255 number

  3. #3
    Member littleiitin's Avatar
    Join Date
    Aug 2011
    Posts
    90
    Rep Power
    15
    Yes Rasm,

    However in some cases you want this differentiation of Upper and Lower case but for one module you need to avoid , then this is useful.

    Thanks

  4. #4
    Member littleiitin's Avatar
    Join Date
    Aug 2011
    Posts
    90
    Rep Power
    15
    Here is simplest Find All Method
    Code:
    Sub FindallM()
        
        Dim rngFind         As Range
        Dim rngWhole        As Range
        Dim rngUnion        As Range
        Dim rngFirstFind    As Range
        Dim rngFirst
        
        Dim strFind     As String
        On Error Resume Next
        strFind = InputBox("Please Enter string to find")
        If Err.Number = 13 Then
            GoTo x1:
        End If
        
        Set rngWhole = ActiveSheet.UsedRange
        Set rngFind = rngWhole.Find(strFind, , , xlPart, , , False)
        If Not rngFind Is Nothing Then
            Set rngUnion = rngFind
            Set rngFirst = rngFind
            Do
                On Error Resume Next
                Set rngFind = rngWhole.FindNext(rngFind)
                Set rngUnion = Union(rngUnion, rngFind)
             Loop Until rngFind.Address = rngFirst.Address
             Err.Clear: On Error GoTo 0: On Error GoTo -1
             rngUnion.Select
        End If
    x1:
    End Sub

Similar Threads

  1. Replies: 1
    Last Post: 06-12-2013, 07:42 PM
  2. Replies: 13
    Last Post: 06-10-2013, 09:05 AM
  3. Replies: 2
    Last Post: 02-06-2013, 12:00 PM
  4. don't copy filtered data if no active cells
    By xander1981 in forum Excel Help
    Replies: 29
    Last Post: 11-01-2012, 06:47 PM
  5. Highlighting Blank Cells
    By Howardc in forum Excel Help
    Replies: 2
    Last Post: 08-13-2012, 07:56 AM

Tags for this Thread

Posting Permissions

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