+ Reply to Thread
Results 1 to 7 of 7

Formatting cells when Formula, (Not Result), contains certain text.

  1. #1
    Registered User
    Join Date
    08-13-2012
    Location
    Woodbury,CT
    MS-Off Ver
    Microsoft? Excel? for Microsoft 365 MSO (Version 2301 Build 16.0.16026.20002) 64-bit
    Posts
    67

    Formatting cells when Formula, (Not Result), contains certain text.

    I have a worksheet with many cells that contain formulas linked to other workbooks. I would like to apply conditional formatting to these cells. The formatting would be based on the contents of the formula, not the result that the formula returns.

    I know how to apply conditional formatting. Where I'm stuck is coming up with a formula to identify the cells I want to format. For example what formula would select all cells containing a formula that includes the text string "Checkbook", so that formatting would be applied to the cell containing:

    ='C:\Users\abc42\Documents\Excel Workbooks\[Checkbook.xlsm]Balances'!$F$8

    I thought I had a solution using a named range containing =FORMULATEXT(!A1), and the following formula in conditional formatting =ISNUMBER(SEARCH("Checkbook",GetFormula)). It works, but if I try to alter the formatting Excel often crashes. I suppose I could get it the way I want it and leave the formatting alone, but I would like a better solution. Excel 2016.

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Formatting cells when Formula, (Not Result), contains certain text.

    Takes a bit of VBA
    Please Login or Register  to view this content.
    Then set up the conditional formatting like so:
    =ISNUMBER(FIND("Check",findformula(A3)))

  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,938

    Re: Formatting cells when Formula, (Not Result), contains certain text.

    Excel formulas (and CF) work based on what a cell displays, not what it actually contains. There is (currently) no formula to detect if another cell contains an entry or a formula

    As a test of this, in A1, enter =count(B1:B100)
    Suppose all cells contained a number, you would see 100 in A1
    Now, in A2, enter =LEFT(A1,2)
    You might expect that to return =C (the 1st 2 letters of =COUNT) but it actually returns 10 (the 1st 2 characters of 100)
    Last edited by FDibbins; 12-30-2015 at 07:24 PM.
    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
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Formatting cells when Formula, (Not Result), contains certain text.

    Quote Originally Posted by FDibbins View Post
    There is (currently) no formula to detect if another cell contains an entry or a formula
    Excel 2013 has 2 "new" functions for this.

    =ISFORMULA(A1) ... returns either TRUE or FALSE

    =FORMULATEXT(A1) ... returns the formula as a text string
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  5. #5
    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,938

    Re: Formatting cells when Formula, (Not Result), contains certain text.

    @ Tony, good info to know, thanks

    I have 2010 here at work (2013 at home), looks like the OP also has 2010

  6. #6
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,612

    Re: Formatting cells when Formula, (Not Result), contains certain text.

    A rather convoluted solution using GET.CELL(41):

    1. For formulas to be used on the worksheet:

    Create an named formula, say,
    Name: CellHasFormula
    refers to: =GET.CELL(41,OFFSET(INDIRECT("RC",FALSE),0,-1))

    note that the: "0, -1" in the OFFSET means that this will only look at the cell to the left of the cell with the formula.

    The formula can be modified, to vary the row or column offset using a named range holding the row or column offset, for example, in this case I just used MYOFFSETVAL for the column offset:

    Name: Test4Formula2
    refers to: =GET.CELL(41,OFFSET(INDIRECT("RC",FALSE),0,MYOFFSETVAL))
    where MYOFFSETVAL refers to G1 which is currently holding "-4"

    2. For Conditional formatting:

    Name: CondFmtTest
    refers to: =GET.CELL(41,INDIRECT("RC",FALSE))
    to be used to conditionally format the cell with the cond.fmt formula
    Attached Files Attached Files
    Ben Van Johnson

  7. #7
    Registered User
    Join Date
    08-13-2012
    Location
    Woodbury,CT
    MS-Off Ver
    Microsoft? Excel? for Microsoft 365 MSO (Version 2301 Build 16.0.16026.20002) 64-bit
    Posts
    67

    Re: Formatting cells when Formula, (Not Result), contains certain text.

    Couple of days late replying, sorry. Thanks for your prompt response. I am working with your suggestion and so far it seems viable. Had to tweak it a little by changing conditional formatting from =ISNUMBER(FIND("Check",findformula(A3))) to =ISNUMBER(FIND("Check",findformula(A1))), and it's working.

    Time will tell if I get any errors or crashes. Thanks for your suggestion!

+ 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. Convert a formula result to text so another formula can find that result
    By rwoollams in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-12-2014, 01:49 AM
  2. Formatting Cells with Date or Text Values in a Conditional Formatting Formula
    By Phil Hageman in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 07-15-2014, 09:36 AM
  3. [SOLVED] Conditional formatting formula based on text in two cells
    By lionrookie in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-08-2014, 12:50 PM
  4. Display formula result if cell is X cells away from text value
    By jimmygig in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-29-2013, 08:30 PM
  5. Adding Text [Formatting?] After Formula Result?
    By tpain123 in forum Excel General
    Replies: 2
    Last Post: 12-03-2009, 03:55 PM
  6. Formatting text which is result of formula
    By starguy in forum Excel General
    Replies: 4
    Last Post: 07-20-2006, 12:20 PM
  7. [SOLVED] conditional formatting based on another cells formula result
    By kstarkey in forum Excel General
    Replies: 3
    Last Post: 10-05-2005, 05:05 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