+ Reply to Thread
Results 1 to 7 of 7

I need a macro to highlight a column having a word which is another column's entry

Hybrid View

  1. #1
    Registered User
    Join Date
    01-23-2013
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    10

    Post I need a macro to highlight a column having a word which is another column's entry

    I need a macro to highlight a column having a word which is another column's entry.

    For example,

    Column 1 is having a sentence "Spectracide Cleaning Solution" and Column 2 is having the Word "Spectracide".

    I want to highlight the column 1 to show that it has the word repeated from Column 2.

    Please help me to create a macro for the same.

    Thanks

  2. #2
    Valued Forum Contributor
    Join Date
    02-09-2012
    Location
    Mauritius
    MS-Off Ver
    Excel 2007
    Posts
    1,055

    Re: I need a macro to highlight a column having a word which is another column's entry

    Hi.

    Try this code:

    Sub HIGHLIGHTTEXT()
        Dim rcnt As Long
        
        rcnt = Range("A" & Rows.Count).End(xlUp).Row
        
        For i = 1 To rcnt
            If InStr(1, Range("A" & i), Range("B" & i)) > 0 Then
                Range("A" & i).Select
                With Selection.Interior
                    .Pattern = xlSolid
                    .PatternColorIndex = xlAutomatic
                    .Color = 65535
                    .TintAndShade = 0
                    .PatternTintAndShade = 0
                End With
            End If
        Next
    End Sub
    Click *, if my suggestion helps you. Have a good day!!

  3. #3
    Registered User
    Join Date
    01-23-2013
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: I need a macro to highlight a column having a word which is another column's entry

    Hi,

    Thanks for the macro.

    I have 2 columns A and B. In column B some entries are blank. When I run the macro, along with the Duplicated text, the entry in Column A gets highlighted which have no entry in column B.

    Please help me to solve this issue.

    Thanks.

  4. #4
    Valued Forum Contributor
    Join Date
    02-09-2012
    Location
    Mauritius
    MS-Off Ver
    Excel 2007
    Posts
    1,055

    Re: I need a macro to highlight a column having a word which is another column's entry

    Now check this code:

    Sub HIGHLIGHTTEXT()
        Dim rcnt As Long
        
        rcnt = Range("A" & Rows.Count).End(xlUp).Row
        
        For i = 1 To rcnt
            If InStr(1, Range("A" & i), Range("B" & i)) > 0 And Range("B" & i) <> "" Then
                Range("A" & i).Select
                With Selection.Interior
                    .Pattern = xlSolid
                    .PatternColorIndex = xlAutomatic
                    .Color = 65535
                    .TintAndShade = 0
                    .PatternTintAndShade = 0
                End With
            End If
        Next
    End Sub

  5. #5
    Registered User
    Join Date
    01-23-2013
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: I need a macro to highlight a column having a word which is another column's entry

    Hi,

    Thanks a lot. Now it's working fine.

  6. #6
    Valued Forum Contributor
    Join Date
    02-09-2012
    Location
    Mauritius
    MS-Off Ver
    Excel 2007
    Posts
    1,055

    Re: I need a macro to highlight a column having a word which is another column's entry

    So if col B is empty then no highlighting. Is that what you want?

  7. #7
    Valued Forum Contributor
    Join Date
    02-09-2012
    Location
    Mauritius
    MS-Off Ver
    Excel 2007
    Posts
    1,055

    Re: I need a macro to highlight a column having a word which is another column's entry

    You are welcome.

    Please click star below. Thanks..

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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