Results 1 to 9 of 9

Adding a macro?

Threaded View

  1. #1
    Registered User
    Join Date
    10-23-2012
    Location
    usa
    MS-Off Ver
    Excel 2010
    Posts
    5

    Adding a macro?

    First off, I'm a relative newbie. I found this macro(?) below and would like to add it to a worksheet because it is supposed to make it possible for me to highlight different words. To customize it to my needs:
    1. where in the string do I add the words that I want highlighted
    2. does it matter if I want to only highlight in one column
    3. once customized how do I make it work on my worksheet.

    Option Explicit
    Sub HighlightCells()
        Dim Lookin As Range, ff As String
        Dim i As Long
        Dim Fnd As Variant
        Dim fCell As Range
        Dim ws As Worksheet
        Dim xitem As Variant
        
       ' Fnd = Array("default", "Google")
     Fnd = Array("Ad hoc", "Adaptable", "Adequate", "And/or", "Approximately", "As a minimum", "As applicable" _
         , "As appropriate", "As possible")
    
        For Each ws In Worksheets
            With ws
                For Each xitem In Fnd
                    Set Lookin = .Cells.Find(xitem, Lookin:=xlValues, LookAt:=xlPart)
                    If Not Lookin Is Nothing Then
                        ff = Lookin.Address
                        Do
                           Lookin.Characters(InStr(1, Lookin, xitem), Len(xitem)).Font.ColorIndex = 3
                            Set Lookin = .Cells.FindNext(Lookin)
                        Loop Until ff = Lookin.Address
                    End If
                    Set Lookin = Nothing
                Next
            End With
        Next
    
    End Sub
    Many thanks!
    Last edited by arlu1201; 10-23-2012 at 01:54 PM. Reason: Use code tags in future.

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