+ Reply to Thread
Results 1 to 3 of 3

Formula or not?

  1. #1
    Alan
    Guest

    Formula or not?

    Hi,
    Is there a formula to establish whether a cell contains a value or a
    formula? What I mean is say A1 contained =10+20 so it shows 30 and it
    contains a formula. If I then paste special values it still shows 30 but
    there is no formula as there would not be in an empty cell. What I'm looking
    for is a formula in another cell which will give a TRUE or FALSE if there is
    a formula in A1 or not.
    TIA,
    Regards,
    Alan.



  2. #2
    Niek Otten
    Guest

    Re: Formula or not?

    Hi Alan,

    A simple User define Function (UDF) will do.

    Function CellHasFormula(a As Range) As Boolean
    CellHasFormula = a.HasFormula
    End Function

    Open the VB editor (ALT+F11)
    From the menu: Insert>Module

    Paste the above function in the module

    Return to the worksheet. You can now use CellHasFormula(A1) as if it were a
    built-in function.

    --

    Kind Regards,

    Niek Otten

    Microsoft MVP - Excel

    "Alan" <alan111@ntlworld.com> wrote in message
    news:eO5u2VzFFHA.2824@tk2msftngp13.phx.gbl...
    > Hi,
    > Is there a formula to establish whether a cell contains a value or a
    > formula? What I mean is say A1 contained =10+20 so it shows 30 and it
    > contains a formula. If I then paste special values it still shows 30 but
    > there is no formula as there would not be in an empty cell. What I'm
    > looking for is a formula in another cell which will give a TRUE or FALSE
    > if there is a formula in A1 or not.
    > TIA,
    > Regards,
    > Alan.
    >




  3. #3
    Alan
    Guest

    Re: Formula or not?

    Hi Niek,
    That is perfect, Thank You!
    Once again my thanks to you and the experts in these newsgroups,
    Regards,
    Alan.

    "Niek Otten" <nicolaus@xs4all.nl> wrote in message
    news:%23wqcm00FFHA.3336@TK2MSFTNGP10.phx.gbl...
    > Hi Alan,
    >
    > A simple User define Function (UDF) will do.
    >
    > Function CellHasFormula(a As Range) As Boolean
    > CellHasFormula = a.HasFormula
    > End Function
    >
    > Open the VB editor (ALT+F11)
    > From the menu: Insert>Module
    >
    > Paste the above function in the module
    >
    > Return to the worksheet. You can now use CellHasFormula(A1) as if it were
    > a built-in function.
    >
    > --
    >
    > Kind Regards,
    >
    > Niek Otten
    >
    > Microsoft MVP - Excel
    >
    > "Alan" <alan111@ntlworld.com> wrote in message
    > news:eO5u2VzFFHA.2824@tk2msftngp13.phx.gbl...
    >> Hi,
    >> Is there a formula to establish whether a cell contains a value or a
    >> formula? What I mean is say A1 contained =10+20 so it shows 30 and it
    >> contains a formula. If I then paste special values it still shows 30 but
    >> there is no formula as there would not be in an empty cell. What I'm
    >> looking for is a formula in another cell which will give a TRUE or FALSE
    >> if there is a formula in A1 or not.
    >> TIA,
    >> Regards,
    >> Alan.
    >>

    >
    >




+ 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