+ Reply to Thread
Results 1 to 9 of 9

Vba change row color based on text

  1. #1
    Registered User
    Join Date
    09-05-2012
    Location
    Dallas, Texas
    MS-Off Ver
    Excel 2013
    Posts
    71

    Vba change row color based on text

    Hello,
    I need to change the font color of the entire row for any cells containing the word BATTERY in a column with named range TEXT1. I have tried conditional formatting, but it only changes the font to green within that column, not the entire row.

    Currently I am also using the code below within this report to change any rows with "000" to red.
    Please Login or Register  to view this content.
    I tried using the same code for the green rows, but nothing happens. Sample of code below:

    Please Login or Register  to view this content.
    Can anyone suggest what am doing wrong?

  2. #2
    Forum Contributor
    Join Date
    09-24-2013
    Location
    Dallas, Texas
    MS-Off Ver
    Excel 2007
    Posts
    128

    Re: Vba change row color based on text

    Question: Are both codes in the same sheet, workbook? if so try changing the Sub call of the 2nd one to something different. Ex( 1st code Sub call is Incomplt_Calls) (2nd code Sub call try Incomplt_Call)

  3. #3
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,939

    Re: Vba change row color based on text

    Conditional Formatting will do this for you. You have to use "use formula" to make it apply to cells other than where the criteria is
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  4. #4
    Valued Forum Contributor xlbiznes's Avatar
    Join Date
    02-22-2013
    Location
    Bahrain
    MS-Off Ver
    Excel 2007
    Posts
    1,223

    Re: Vba change row color based on text

    Hi,

    changes made to your code to give the desired result :

    Please Login or Register  to view this content.
    Happy Computing ,

    Xlbiznes.

    To show your appreciation please click *

  5. #5
    Registered User
    Join Date
    09-05-2012
    Location
    Dallas, Texas
    MS-Off Ver
    Excel 2013
    Posts
    71

    Re: Vba change row color based on text

    Ooops! No, the first is Incomplt_Calls (red) and the second is Battery_Calls.

  6. #6
    Registered User
    Join Date
    09-05-2012
    Location
    Dallas, Texas
    MS-Off Ver
    Excel 2013
    Posts
    71

    Re: Vba change row color based on text

    OK, so I've tried conditional formatting with a few different formulas and none of them work. I do import the data as text, but don't know if that would have anything to do with the problem.

    I used the following steps and formulas listed below.
    • Conditional Formatting
    • New Rule
    • Use a Formula to determine which cells to format
    • Enter Formulas
    • Format font
    • OK
    • "Manage Rules"
    • In the "Applies to" box =$A$1:$AN$783

    Formulas tried:
    • =INDIRECT("o"&ROW())="*BATTERY*"
    • =IF($O$2="*BATTERY*", TRUE, FALSE)
    • =$O:$O="*BATTERY*"

  7. #7
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,939

    Re: Vba change row color based on text

    without seeing any data...
    =search("Battery",$O$2,1)

    When using a formula in CF, you just need the bare bones. It works on TRUE/FALSE, so if the search finds something = TRUE, if not, = error= FALSE

  8. #8
    Registered User
    Join Date
    09-05-2012
    Location
    Dallas, Texas
    MS-Off Ver
    Excel 2013
    Posts
    71

    Re: Vba change row color based on text

    That works perfect!!! I could not find anything on the web telling me to utilize a formula like that.

    Man I wish I could give you some cookies or something. You are always so helpful. I truly appreciate all of your help.

    Thank you!!!

  9. #9
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,939

    Re: Vba change row color based on text

    Happy to help, and thanks for the kind words - cookies would be great, but the thought is even better

+ 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. [SOLVED] Change Tab color based on text in a cell
    By Gcorn38055 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-08-2013, 11:22 AM
  2. change row color based on text
    By vbjohn in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-03-2011, 12:39 PM
  3. Excel 2007 : Formula to change text color based on value?
    By NvrEvrGvUp in forum Excel General
    Replies: 4
    Last Post: 11-02-2010, 05:18 PM
  4. change text color based on background color
    By great.bean in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-05-2009, 07:07 PM
  5. change text color based on adjacent cell text color
    By matthewst in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 03-01-2005, 03:49 PM

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