+ Reply to Thread
Results 1 to 2 of 2

changing the color on range in a column when text is in a certain row

Hybrid View

Romulo changing the color on range... 07-27-2012, 11:36 AM
tigeravatar Re: changing the color on... 07-27-2012, 12:13 PM
  1. #1
    Registered User
    Join Date
    07-19-2012
    Location
    Washington DC
    MS-Off Ver
    Excel 2013
    Posts
    36

    changing the color on range in a column when text is in a certain row

    below is the conditional formatting recorded

    for String:= I need it to read a string variable. I need it to reference a two digit country code that has been looked up from another sheet.

    after, i want to highlight a certain range like A1 to N1

    then i want it to do do this for all of Column N.

    can i modify this code a bit or do I need to start from scratch.

        
    Columns("N:N").Select
        Selection.FormatConditions.Add Type:=xlTextString, String:="PH", _
            TextOperator:=xlContains
        Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
        With Selection.FormatConditions(1).Interior
            .PatternColorIndex = xlAutomatic
            .ColorIndex = xlAutomatic
        End With
        Selection.FormatConditions(1).StopIfTrue = False
    any and all help would be much appreciated.

  2. #2
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: changing the color on range in a column when text is in a certain row

    Romulo,

    You should be able to modify that code. If the 2-character country code is on Sheet2 cell A1, it would look like this:
        
    Columns("N:N").Select
        Selection.FormatConditions.Add Type:=xlTextString, String:=Sheets("Sheet2").Range("A1").Value, _
            TextOperator:=xlContains
        Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
        With Selection.FormatConditions(1).Interior
            .PatternColorIndex = xlAutomatic
            .ColorIndex = xlAutomatic
        End With
        Selection.FormatConditions(1).StopIfTrue = False
    Hope that helps,
    ~tigeravatar

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

+ 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