+ Reply to Thread
Results 1 to 9 of 9

highlight column cells red when there is a 0

  1. #1
    Registered User
    Join Date
    01-28-2014
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2016
    Posts
    43

    highlight column cells red when there is a 0

    I have a file that has a column of data that pulls a quantity on hand using a vlookup and I want to highlight the cells that return a 0 by filling the cell with a color like red.
    Is there an easy VBA code to do this or is there another way to do this without having to add columns?

    Any help with this would be appreciated.

  2. #2
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,064

    Re: highlight column cells red when there is a 0

    Try Condtional Formatting

    Select the entire range you want to highlight, (e.g. A1:A100)

    Conditional Formatting
    New Rule
    Use a formula to determine...

    =(A1=0)

    Format as required
    Regards
    Special-K

    Ensure you describe your problem clearly, I have little time available to solve these problems and do not appreciate numerous changes to them.

  3. #3
    Registered User
    Join Date
    01-28-2014
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2016
    Posts
    43

    Re: highlight column cells red when there is a 0

    Is there a trick to getting conditional formatting to work in cells that already have a formula?

  4. #4
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,064

    Re: highlight column cells red when there is a 0

    You can have more than one conditional format in a cell.
    What conditional formatting exists in the cells at the moment?

  5. #5
    Registered User
    Join Date
    01-28-2014
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2016
    Posts
    43

    Re: highlight column cells red when there is a 0

    I have a vlookup in the column that I would like to use the conditional formatting.

  6. #6
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,064

    Re: highlight column cells red when there is a 0

    You need to explain clearly what you're trying to do.

    You asked to highlight a cell when it is zero.
    I have given you the solution on how to do that.

    It doesn't matter if the cell contains a value or a formula.
    Condtional formatting looks at the cell value (whether its a value entered directly from the keyboard or its the result of a formula).
    You don't need to put a VLOOKUP in the conditional formatting, just checking the result of the cell that contains the VLOOKUP is enough (and probably quicker).

    If you're still stuck post the file with a CLEAR description of what you're trying to achieve, ie what the VLOOKUP formula is (as I dont fancy spending all day guessing).

  7. #7
    Registered User
    Join Date
    01-28-2014
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2016
    Posts
    43

    Re: highlight column cells red when there is a 0

    Here is an example of what I am trying to do. Column D of Master sheet is where I would like to have the "0" highlighted and it is also doing a vlookup?
    I left the conditional formatting that I tried in column D so you can see what I am doing wrong.
    Thank you for you patience, I look forward to the solution that you share.
    Attached Files Attached Files

  8. #8
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,064

    Re: highlight column cells red when there is a 0

    1. Change the formula in D2 to

    =IFERROR(VLOOKUP(B2,'Daily reload file'!B:E,3,0),0)

    0 is a number, "0" is text - the condtional formatting formula is checking for 0 as a number not text

    Copy the formula from D2 down to D23.

    2. Select D2:D23
    Conditional Formatting
    New Rule
    Use a formula to determine...

    =(D2=0)

    format as green

  9. #9
    Registered User
    Join Date
    01-28-2014
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2016
    Posts
    43

    Re: highlight column cells red when there is a 0

    Amazing, I am just starting to learn how to use excel/vba and really appreciate support from masters like yourself!!

    Thank you!!

+ 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. Conditional Format: Highlight cells in Column C that refer to Column B
    By agf12555 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-26-2015, 05:16 PM
  2. Replies: 2
    Last Post: 04-17-2014, 03:30 PM
  3. HELP! Compare cells of a column to same column in different workbook and highlight diffs
    By bradleyherron in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-05-2014, 10:18 AM
  4. Replies: 5
    Last Post: 09-24-2012, 05:14 PM
  5. Replies: 23
    Last Post: 09-25-2009, 07:39 PM
  6. Replies: 1
    Last Post: 09-19-2009, 08:09 PM
  7. Replies: 3
    Last Post: 08-07-2009, 12:03 PM

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