+ Reply to Thread
Results 1 to 8 of 8

the code is finding repeated values but i need to search values from E column to D

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    03-01-2014
    Location
    Mysore
    MS-Off Ver
    Excel 2007
    Posts
    379

    the code is finding repeated values but i need to search values from E column to D

    i have one column(SEARH WORD) Where i has some words
    like
    CABLE
    CONNECTOR
    CLIP
    BELT....ETC

    I NEED TO FIND THIS WORDS IN OTHER COLUMN (XX) AND MARK COLOR(YELLOOW)



    Sub SER()
    '
        
       Fnd = InputBox("Enter text!", "SERACH_TEXT")
       ' Fnd = "#MULTIVALUE"
        Cells.Find(What:=(Fnd), After:=ActiveCell, LookIn:=xlFormulas, _
        LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False).Activate
         'Rows("51:51").Select
        With Selection.Interior
            .ColorIndex = 6
            .Pattern = xlSolid
            .PatternColorIndex = xlAutomatic
            
        End With
    'End Sub
    
    'Cells.FormatConditions.Delete
    End Sub
    
    
    Public Sub SER2()
    Dim rngArea As Range
    Dim Fnd As Variant
    
    Fnd = InputBox("Enter text!", "SEARCH_TEXT")
    For Each rngArea In Selection
    'Prije bilo For Each rngArea In Selection.Areas
        With rngArea
        If InStr(UCase(rngArea.Value), UCase(Fnd)) > 0 Then
            With rngArea.Interior
            .ColorIndex = 6
            .Pattern = xlSolid
            .PatternColorIndex = xlAutomatic
            End With
        End If
        End With
    Next rngArea
    End Sub
    Attached Files Attached Files

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: the code is finding repeated values but i need to search values from E column to D

    Hello baig123,

    Try this macro and let me know th results.

    Sub FindAndColor()
    
        Dim Cell    As Variant
        Dim FndWhat As String
        Dim RegExp  As Object
        
            FndWhat = InputBox("Enter text!", "SEARCH_TEXT")
            
            Set RegExp = CreateObject("VBScript.RegExp")
            RegExp.IgnoreCase = True
            RegExp.Pattern = "\b" & FndWhat & "\b"
            
            For Each Cell In Selection
                Set Matches = RegExp.Execute(Cell)
                If Matches.Count > 0 Then
                   Cell.Interior.ColorIndex = 6
                   Cell.Interior.Pattern = xlSolid
                End If
            Next Cell
            
    End Sub
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Forum Contributor
    Join Date
    03-01-2014
    Location
    Mysore
    MS-Off Ver
    Excel 2007
    Posts
    379

    Re: the code is finding repeated values but i need to search values from E column to D

    No its dosent display any output

    i have already specified words in column e what to find in column(d)

    i need to run macro search in the column d

    here searching for multiple values like

    BELT
    CAble
    CONNECTOR
    CLIP
    CLAMP
    Last edited by baig123; 10-13-2014 at 01:40 AM. Reason: PARAGRAPH

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: the code is finding repeated values but i need to search values from E column to D

    Hello baig123,

    Are you searching for full word matches or part word matches?

    Do you want highlight the cell if any of these words are found?

    Please provide accurate details about what you want to do.

  5. #5
    Forum Contributor
    Join Date
    03-01-2014
    Location
    Mysore
    MS-Off Ver
    Excel 2007
    Posts
    379

    Re: the code is finding repeated values but i need to search values from E column to D

    yes i am finding both part words

    i want to highlight with color mark yellow for cells

    sorry for any confusion
    Last edited by baig123; 10-13-2014 at 05:06 AM. Reason: paragraph

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: the code is finding repeated values but i need to search values from E column to D

    Hello baig123,

    It took quite a bit of time for to verify the macro was working correctly due to the large data set. A button has been added to the sheet to run the macro below.

    Each cell in column "D" is checked for any of the words in column "E". The case is ignored and full words only are matched.

    Sub FindAndColor()
    
        Dim Cell        As Variant
        Dim FndWhat     As String
        Dim RegExp      As Object
        Dim RngBeg      As Range
        Dim RngEnd      As Range
        Dim SearchWords As Variant
        Dim Word        As Variant
        
        
            Set RngBeg = Range("E2")
            Set RngEnd = Cells(Rows.Count, "E").End(xlUp)
            If RngEnd.Row < RngBeg.Row Then Exit Sub
            
            SearchWords = Range(RngBeg, RngEnd).Value
            
            Set RngBeg = Range("D2")
            Set RngEnd = Cells(Rows.Count, "D").End(xlUp)
            If RngEnd.Row < RngBeg.Row Then Exit Sub
            
            Set RegExp = CreateObject("VBScript.RegExp")
            RegExp.IgnoreCase = True
            
            Application.ScreenUpdating = False
            
                For Each Word In SearchWords
                    RegExp.Pattern = "\b" & Word & "\b"
                    For Each Cell In Range(RngBeg, RngEnd)
                        If RegExp.Execute(Cell).Count > 0 Then
                            Cell.Interior.ColorIndex = 6
                            Cell.Interior.Pattern = xlSolid
                        End If
                    Next Cell
                Next Word
            
            Application.ScreenUpdating = True
            
    End Sub
    Attached Files Attached Files

  7. #7
    Forum Contributor
    Join Date
    03-01-2014
    Location
    Mysore
    MS-Off Ver
    Excel 2007
    Posts
    379

    Re: the code is finding repeated values but i need to search values from E column to D

    thanks for helping leith ross

  8. #8
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: the code is finding repeated values but i need to search values from E column to D

    Hello baig123,

    You're welcome.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 1
    Last Post: 10-11-2014, 04:52 AM
  2. [SOLVED] create list of unique values from a column with repeated values?
    By Chad Schaben in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 10:05 AM
  3. create list of unique values from a column with repeated values?
    By Anne Troy in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-06-2005, 07:05 AM
  4. [SOLVED] create list of unique values from a column with repeated values?
    By Chad Schaben in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 01:05 AM
  5. [SOLVED] create list of unique values from a column with repeated values?
    By Chad Schaben in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 12:05 AM

Tags for this Thread

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