+ Reply to Thread
Results 1 to 6 of 6

Return True/False if cell contains formula

  1. #1
    Registered User
    Join Date
    05-07-2008
    Location
    Milwaukee, Wisconsin
    Posts
    55

    Return True/False if cell contains formula

    Is there a formula or VB code like the =TYPE() function that will return whether a cell contains a FORMULA?

    Here's the issue:
    I'm writing a macro to update 10,000 sheets. Each sheet has a column that I'm updating with a new formula. Some of these formulas have been previously overwritten with a random number that would delete the formula from the cell. I have to leave the overwritten values where there is no formula, and replace the values of the formulas where they are still intact.

    I assume that if I can identify whether there is a formula in the cell or not, I can choose that cell to skip or update. Ideas?

    Here is an example formula that would be in a cell (that I would want "identified" as containing a formula):
    Please Login or Register  to view this content.
    Thanks!
    Last edited by VBA Noob; 04-09-2009 at 03:48 PM.
    Ryan Ziegler
    Systems Administrator

    Timber Creek Resource, LLC
    Midwest's Largest Manufacturer of Custom Pallets, Boxes, and Crates.

    Click here to visit our website: Pallets, Boxes, Crates from Milwaukee, Wisconsin

  2. #2
    Forum Expert ConneXionLost's Avatar
    Join Date
    03-11-2009
    Location
    Victoria, Canada
    MS-Off Ver
    2010
    Posts
    2,952

    Re: Return True/False if cell contains formula

    Not quite, but you can build a UDF that will by using:

    Please Login or Register  to view this content.
    HTH

    Cheers,
    Would you like to say thanks? Please click the: " Add Reputation" button, on the grey bar below the post.

  3. #3
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Return True/False if cell contains formula

    You can use SpecialCells to identify Cells containing Formulae if that's your intent...

    Please Login or Register  to view this content.
    The range can be restricted further to a column, row or range of cells, the above simply overrides all Formulas on the active sheet with the text "override"

    I'm not entirely sure what it is you're trying to do...

    (the same can be applied in terms of xlCellTypeConstants rather than Formulas etc... see: http://msdn.microsoft.com/en-us/libr...ffice.11).aspx)

  4. #4
    Registered User
    Join Date
    05-07-2008
    Location
    Milwaukee, Wisconsin
    Posts
    55

    Re: Return True/False if cell contains formula

    Thanks for such a fast reply.

    I've never used a UDF before and I've never heard of SpecialCells, so I'm going to look into those possibilities.

    I will post a reply if I figure out a solution.

  5. #5
    Forum Expert ConneXionLost's Avatar
    Join Date
    03-11-2009
    Location
    Victoria, Canada
    MS-Off Ver
    2010
    Posts
    2,952

    Re: Return True/False if cell contains formula

    Sorry, I guess I coulda 'splain'd that a little better.

    How to Create Excel User Defined Functions (UDF)

    Open up a new workbook.
    Get into VBA (Press Alt+F11)
    Insert a new module (Insert > Module)
    - Copy and Paste the Excel user defined function "ISFORMULA" -
    Get out of VBA (Press Alt+Q)
    Use the functions (They will appear in the Paste Function dialog box, Shift+F3, under the "User Defined" category)
    If you want to use a UDF in more than one workbook, you can save your functions in your own custom add-in. Simply save your excel file that contains your VBA functions as an add-in file (.xla). Then load the add-in (Tools > Add-Ins...). Warning! Be careful about using custom functions in spreadsheets that you need to share with others. If they don't have your add-in, the functions will not work when they use the spreadsheet.

    These instructions are copied from Vertex42 if you need further info.

    HTH

    Cheers,

  6. #6
    Registered User
    Join Date
    05-07-2008
    Location
    Milwaukee, Wisconsin
    Posts
    55

    Re: Return True/False if cell contains formula

    Thanks everyone. I ended up using Donkey's SpecialCells idea. It worked very well!

    Here is the portion of the code that was used:
    Please Login or Register  to view this content.
    Thanks Again for the help!

+ 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