+ Reply to Thread
Results 1 to 5 of 5

Issue with formula on conditional formatting

  1. #1
    Forum Contributor
    Join Date
    05-03-2013
    Location
    Costa Rica
    MS-Off Ver
    MS Excel 365
    Posts
    120

    Issue with formula on conditional formatting

    hello there!

    I have an issue when using conditional formatting to highlight cells with certain conditions.

    Here's my situation:

    I have a workbook where Sheet1 has cells with values only. There are no formulas.
    On Sheet2, I have the following formula on some cells:

    =IF(Sheet1!A1<>"",Sheet1!A1,"")

    Obvioulsy, the cell name varies as I copy and paste the formula on the lower cells.

    I tried to use conditional formatting on Sheet2 so as to highlight cells using 2 conditions:

    1- create borders around cells with a formula
    2- create a yellow pattern on those cells whose formula DID NOT result in an empty cell.

    If you see the image attached to this post, you'll see the 2 conditions I have set up on Excel 2003 conditional formatting feature.

    The first condition is based on the following code I embedded on my workbook:

    Function IsFormula(cell_ref As Range)
    IsFormula = cell_ref.HasFormula
    End Function


    The second one is also based on that code/formula, and shows what I thought to be the condition I was looking for (to highlight in yellow all cells whose formula DID NOT result in an empty cell. However, only the first seems to be working. Can someone help me? Maybe I've made a mistake on condition 2.
    Attached Images Attached Images

  2. #2
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Issue with formula on conditional formatting

    maybe
    =AND(IsFormula(A1),A1<>"")
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  3. #3
    Forum Contributor
    Join Date
    05-03-2013
    Location
    Costa Rica
    MS-Off Ver
    MS Excel 365
    Posts
    120

    Re: Issue with formula on conditional formatting

    hi there! It did not work!

  4. #4
    Forum Contributor
    Join Date
    12-22-2010
    Location
    Rio, Brazil
    MS-Off Ver
    Excel 2010, 2016
    Posts
    209

    Re: Issue with formula on conditional formatting

    Maybe...

    Change Condition 1 to
    =AND(IsFormula(A1),A1="") ---> Borders

    Condition 2
    =AND(IsFormula(A1),A1<>"") ---> Fill = yellow
    Marcelo Branco

  5. #5
    Forum Contributor
    Join Date
    05-03-2013
    Location
    Costa Rica
    MS-Off Ver
    MS Excel 365
    Posts
    120

    Re: Issue with formula on conditional formatting

    Guys! Thanks for your help!

    I just find the way to do it.
    I had to switch formats to do so: to highlight cells with a formula, I chose to fill with a color instead of creating borders; and to highlight those cells with a formula that DID NOT result in an empty cell, I chose to create borders around them instead of coloring in yellow, so this is how I did it:

    I used this code to highlight in yellow cells with a formula:

    Sub Highlight_FormulaCells()
    'Apply yellow highlight to all formula cells.
    Dim ws As Worksheet
    Dim rng As Range
    Set ws = ActiveSheet
    For Each rng In ws.Cells.SpecialCells(xlCellTypeFormulas)
    rng.Interior.ColorIndex = 6
    Next rng
    End Sub


    Then I set conditional formatting to create borders using this condition =CELL("contents",A1)<>""

+ 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 Formatting issue
    By roenajoyave in forum Excel - New Users/Basics
    Replies: 3
    Last Post: 07-12-2013, 12:00 PM
  2. [SOLVED] Conditional Formatting - formula issue
    By Bjordion in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-06-2012, 03:39 PM
  3. Conditional Formatting Issue
    By bumperbg in forum Excel General
    Replies: 0
    Last Post: 07-06-2011, 04:19 AM
  4. Conditional formatting issue
    By Cramer19 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-31-2007, 01:29 PM
  5. Conditional Formatting Issue
    By afsoares in forum Excel General
    Replies: 3
    Last Post: 06-30-2006, 08:40 AM

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