Contact US

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Formula OR value in cell?

Formula OR value in cell?

Formula OR value in cell?

Can anyone tell me how to test whether a cell contains a directly input value or a formula so that I can use the test in a conditional format?
e.g. if a cell SHOWS 7, test is it a directly entered 7, or is it the result of a formula say =4+3?

RE: Formula OR value in cell?

Checking for a '='sign does not work in combination with a .Value instruction because .Value always gives the same result as you see in Excel. The .Formula instruction however does show the fysical input of the cell. So use this in combination with an if or case statement.

MsgBox Range("A1").Formula

For example
Entered formula 7 / =3+4
.Value               7 / 7
.Formula           7 / =3+4

Now you can check whether there's a formula or a value in the cell.



RE: Formula OR value in cell?

There's a function =TYPE() what suppose to return 8 in the case of formula in the argument, but it never does (at least in Excel97). the other way to determine if cell contains a number or formula is to write a custom function in VBA:

Public function ISFORMULA(rng as range) as boolean
end function

declaring a function as public will make accessible from the worksheet.
Try it!

RE: Formula OR value in cell?

If you know how to define a named ranged then try this:

Define a range
Name:  IsFormula
Refers to:  =LEFT(GET.CELL(6,INDIRECT("rc",FALSE)),1)="="

Then get out of this dialog box.

Next, select the all of the sells that you would like to conditionally format (that is, select all of the cells that you would like to test for a formula).

Go to the conditional format dialog box and type this condition:

Formula Is:  =IsFormula

RE: Formula OR value in cell?

to: a3a
Thanks - your solution works fine & I will use it.  

However I don't understand how it works, because there is no reference in Excel help index (Excel 97)to the "GET.CELL" function nor to the particular variant of the "INDIRECT" function you use.

RE: Formula OR value in cell?

To: yakpol
Thanks - your solution works fine too. I shied away from using it at first (scared of the VBA word!), but I can see now that by having it as a Public Function in my Personal.xls , that I can use it on any spreadsheet without having to enter lengthy formulae in the conditional formatting.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login


Low-Volume Rapid Injection Molding With 3D Printed Molds
Learn methods and guidelines for using stereolithography (SLA) 3D printed molds in the injection molding process to lower costs and lead time. Discover how this hybrid manufacturing process enables on-demand mold fabrication to quickly produce small batches of thermoplastic parts. Download Now
Design for Additive Manufacturing (DfAM)
Examine how the principles of DfAM upend many of the long-standing rules around manufacturability - allowing engineers and designers to place a part’s function at the center of their design considerations. Download Now
Taking Control of Engineering Documents
This ebook covers tips for creating and managing workflows, security best practices and protection of intellectual property, Cloud vs. on-premise software solutions, CAD file management, compliance, and more. Download Now

Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close