+ Reply to Thread
Results 1 to 5 of 5

How to detect a formula in a cell

  1. #1
    Registered User
    Join Date
    04-26-2007
    Posts
    3

    Question How to detect a formula in a cell

    Hi everybody,

    I would need to be able to identify (in a formula) if a given cell contains a formula or a "hard-coded" number.
    (The final aim is to have a conditional formatting for the background color of this cell).

    Of course, I can't use ISNUMBER as the result of the formula might be a number as well...

    Thanks in advance for any good advice!

  2. #2
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,454
    Hi,

    you could do

    Edit > Go to> Special> Formulas
    Rule 1: Never merge cells
    Rule 2: See rule 1

    "Tomorrow I'm going to be famous. All I need is a tennis racket and a hat".

  3. #3
    Registered User
    Join Date
    04-26-2007
    Posts
    3
    Quote Originally Posted by sweep
    Hi,

    you could do

    Edit > Go to> Special> Formulas
    Thanks Dave, but what I try to achieve, with a conditional formatting, is to have the background of a cell, let's say, in red if the cell contains a hard-coded number, and in blue if it contains a formula.

    By default all the cells would contain formula (they will thus be in blue). As soon as the user scratches a formula with a hard-coded number, then the cell gets red.

    Question still open!

  4. #4
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Good afternoon mikop

    OK, put this function in an ordinary code module :

    Please Login or Register  to view this content.
    Then go to the cell you want to check and select Format > Conditional Formatting, select FormulaIa and use this formula (assuming cell A1) :

    =IsAFormula($A$1)=TRUE

    and select your format.

    HTH

    DominicB
    Please familiarise yourself with the rules before posting. You can find them here.

  5. #5
    Registered User
    Join Date
    04-26-2007
    Posts
    3
    Quote Originally Posted by dominicb
    Good afternoon mikop

    OK, put this function in an ordinary code module :

    Please Login or Register  to view this content.
    Then go to the cell you want to check and select Format > Conditional Formatting, select FormulaIa and use this formula (assuming cell A1) :

    =IsAFormula($A$1)=TRUE

    and select your format.

    HTH

    DominicB
    Hello DominicB,

    Thanks very much! It works (of course).

    I should definitely invest some time in learning to program instead of struggling all the time with my poor set of Excel functions!

    Have a very nice day

+ 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