+ Reply to Thread
Results 1 to 16 of 16

Formula to detect formulas?

  1. #1
    Registered User
    Join Date
    12-20-2007
    Posts
    17

    Question Formula to detect formulas?

    Hi all,

    Without using VB or some script, is there a way to determine if a cell contains a hard coded numeric value versus a formula that is determining a value? I need to perform certain actions if a cell is hard inputted, and certain other actions if it contains a formula. Any ideas?

    Thank you!
    Dan

  2. #2
    Valued Forum Contributor quekbc's Avatar
    Join Date
    01-18-2010
    Location
    Sydney, Australia
    MS-Off Ver
    2010, 2013, 2016
    Posts
    1,149

    Re: Formula to detect formulas?

    Try this.

    Define a new name. (Insert, Name, Define or Formulas --> Name Manager)

    Choose a name, say, IsFormula
    And type this in the RefersTo section
    Please Login or Register  to view this content.
    This will return TRUE if there is a formula in A1, FALSE if its a hardcoded number/text/blank
    Last edited by quekbc; 10-13-2011 at 10:57 AM. Reason: Indirect not required.

  3. #3
    Forum Expert Whizbang's Avatar
    Join Date
    08-05-2009
    Location
    Greenville, NH
    MS-Off Ver
    2010
    Posts
    1,395

    Re: Formula to detect formulas?

    http://www.ozgrid.com/forum/showthre...t=80337&page=1

    After doing some Googling, it looks like this is not possible without VBA.

    You could do something like this:

    =CELL("type",A1)

    But that will only tell you if the cell is blank, text, or something else.

  4. #4
    Valued Forum Contributor quekbc's Avatar
    Join Date
    01-18-2010
    Location
    Sydney, Australia
    MS-Off Ver
    2010, 2013, 2016
    Posts
    1,149

    Re: Formula to detect formulas?

    More description to my post above.

    In any cell if you type in
    Please Login or Register  to view this content.
    It will show TRUE if A1 is a formula, FALSE if its a hardcoded number/text/blank

  5. #5
    Forum Expert Whizbang's Avatar
    Join Date
    08-05-2009
    Location
    Greenville, NH
    MS-Off Ver
    2010
    Posts
    1,395

    Re: Formula to detect formulas?

    quekbc,

    That's pretty neat. I am not sure if this will work for the OP, because it would require making a named formula for each cell he wants to check, but I certainly am happy to have learned of this little trick (though I can't think of a practical application at the moment).

    One thing, why does it work as a named formula but not as a formula on the worksheet?

    **Edit**

    Also tried it as a conditional format formula, but no go. Wierd.

  6. #6
    Registered User
    Join Date
    12-20-2007
    Posts
    17

    Re: Formula to detect formulas?

    This is a good start - thank you! Unfortunately, this looks like since it's defining a name for one specific cell, it can only be used on one cell. I suppose I should have specified I need to run this test on numerous cells throughout a model. Any way to use this approach but specify which cells to test?

    Thanks!

  7. #7
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Formula to detect formulas?

    Hi,

    Why the reluctance to use a macro or a UDF?
    In this case it would be much simpler.

    Regards
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  8. #8
    Valued Forum Contributor quekbc's Avatar
    Join Date
    01-18-2010
    Location
    Sydney, Australia
    MS-Off Ver
    2010, 2013, 2016
    Posts
    1,149

    Re: Formula to detect formulas?

    In that case,

    If there is a pattern to where you put your formulas, say for example, you want to test whether the value in column E is a formula or not, you can use...

    Please Login or Register  to view this content.
    Or say, if you want the to use the IsFormula function immediately to the right of the value in question, you can use,
    Please Login or Register  to view this content.

    Quote Originally Posted by Whizbang View Post
    One thing, why does it work as a named formula but not as a formula on the worksheet?

    **Edit**

    Also tried it as a conditional format formula, but no go. Wierd.
    From what I know, the Get.Cell function is an old school macro function (xl4). This function has been removed from Excel but we can still "cheat" excel into using it and that is by using named ranges to type it in.
    Last edited by quekbc; 10-13-2011 at 11:14 AM.

  9. #9
    Valued Forum Contributor quekbc's Avatar
    Join Date
    01-18-2010
    Location
    Sydney, Australia
    MS-Off Ver
    2010, 2013, 2016
    Posts
    1,149

    *delete*

    *deleted* *deleted*
    Last edited by quekbc; 10-13-2011 at 11:18 AM. Reason: Totally have no idea on how to delete posts...

  10. #10
    Forum Expert Whizbang's Avatar
    Join Date
    08-05-2009
    Location
    Greenville, NH
    MS-Off Ver
    2010
    Posts
    1,395

    Re: Formula to detect formulas?

    Brilliant, quekbc!

    Here is a link that give some great info on this method:
    http://www.mrexcel.com/forum/showthread.php?t=20611
    Last edited by Whizbang; 10-13-2011 at 11:23 AM.

  11. #11
    Forum Expert Whizbang's Avatar
    Join Date
    08-05-2009
    Location
    Greenville, NH
    MS-Off Ver
    2010
    Posts
    1,395

    Re: Formula to detect formulas?

    I had to add quotes to your formula to get it to work:

    =GET.CELL(48,INDIRECT("Sheet1!RC[-1]",FALSE))

  12. #12
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,169

    Re: Formula to detect formulas?

    I guess using Show Formulas is no use for the OP?
    http://spreadsheets.about.com/od/exc...w_formulas.htm

    Also using PUP found at http://spreadsheetpage.com/index.php/pupv7/home
    has a utility to map a spreadsheet and determine if a cell is a value or formula.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  13. #13
    Valued Forum Contributor quekbc's Avatar
    Join Date
    01-18-2010
    Location
    Sydney, Australia
    MS-Off Ver
    2010, 2013, 2016
    Posts
    1,149

    Re: Formula to detect formulas?

    Quote Originally Posted by Whizbang View Post
    I had to add quotes to your formula to get it to work:

    =GET.CELL(48,INDIRECT("Sheet1!RC[-1]",FALSE))
    Oh, yes. You're right. Missed that last bit. Thanks!

  14. #14
    Forum Expert Whizbang's Avatar
    Join Date
    08-05-2009
    Location
    Greenville, NH
    MS-Off Ver
    2010
    Posts
    1,395

    Re: Formula to detect formulas?

    MarvinP,
    The OP didn't say, but I can see where having a formula to determine this can be useful, either as conditional formatting, or to combine with an IF() function and cause certain calculations or text to appear.

    Also, the OP could use the Go To Special dialog box to select constants or formulas.

  15. #15
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,274

    Re: Formula to detect formulas?

    Quote Originally Posted by Whizbang View Post
    I had to add quotes to your formula to get it to work:

    =GET.CELL(48,INDIRECT("Sheet1!RC[-1]",FALSE))
    If you remove the sheet name, then it will work on any sheet (which is really the point of using INDIRECT):

    =GET.CELL(48,INDIRECT("RC[-1]",FALSE))

    for example to do the cell to the left of wherever you enter it.
    Remember what the dormouse said
    Feed your head

  16. #16
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Formula to detect formulas?

    I've used the following in conjunction with Conditional Formatting

    ISFORMULA =GET.CELL(48,INDIRECT("rc",FALSE))

    Then select the entire sheet or used range and in conditional formatting
    using formula = IsFormula Format as needed.
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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