Consulting

Results 1 to 8 of 8

Thread: Solved: How to Detect Formula Is Present

  1. #1

    Solved: How to Detect Formula Is Present

    I thought I had seen a function called ISFORMULA somewhere, but perhaps not. What's the best non-VBA way to detect if a cell contains a formula or not?

  2. #2
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    You can't without VBA. A UDF would look like this ...


    [vba]Option Explicit

    Public Function IsFormula(celRef As Range) As Boolean
    IsFormula = celRef.HasFormula
    End Function[/vba]

  3. #3
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Hi Sid,
    You could use Edit/GoTo/Special/Formula/OK and colour the selected cells for a quick visual check.
    Regards
    Malcolm
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  4. #4
    Thanx, guys. I was hoping that somewhere there was a function I could use in a formula. I suppose I could use Zack's contribution and put it in my Personal.xls for general reference. Thanx, Zack.

  5. #5

  6. #6
    Oops ... I KNEW I had seen it somewhere.

  7. #7
    VBAX Contributor
    Joined
    Oct 2004
    Posts
    159
    Location
    Quote Originally Posted by Cyberdude
    I thought I had seen a function called ISFORMULA somewhere, but perhaps not. What's the best non-VBA way to detect if a cell contains a formula or not?
    May be you are looking for Macro 4.0 GET.FORMULA

    Suppose A1 = Sin(45)
    1. Insert - Name - Define
    2. Names in Workbooks: IsFormulaThere
    3. Refer to: =GET.FORMULA(!$A$1)
    C1= IsFormulaThere --> shows "= Sin(45)"

  8. #8
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Quote Originally Posted by Emily
    May be you are looking for Macro 4.0 GET.FORMULA

    Suppose A1 = Sin(45)

    1. Insert - Name - Define
    2. Names in Workbooks: IsFormulaThere
    3. Refer to: =GET.FORMULA(!$A$1)
    C1= IsFormulaThere --> shows "= Sin(45)"

    Excel4 macros are notoriously unstable, copying and pasting the formula to another worksheet is know to cause Excel to crash. This is one situation where I would reverse my maxim of using Excel functioanlity where possible. the VBA solution is just so much safer.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •