MrExcel Message Board

Go Back   MrExcel Message Board > Question Forums > Excel Questions

Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only.

Reply
 
Thread Tools Display Modes
Old Mar 6th, 2002, 08:51 AM   #1
Scott in Phoenix
New Member
 
Join Date: Mar 2002
Location: Arizona
Posts: 12
Default

Hi!

Love the new board. This BB client is awesome - used it before. I like!

QUESTION:
How can I tell if a cell contains a formula or if it contains text? This is driving me NUTS!

Any functions I try all look at the VALUE of the cell, rather than the CONTENTS of the cell. I need to be able to differentiate between cells that contain text, and cells that have a formula that references the text.

I need to be able to do this via a formula or function, so that I can apply Conditional Formatting to the cells that contain the actual text.

Can anybody help??

Thanks in advance.

Scott
Scott in Phoenix is offline   Reply With Quote
Old Mar 6th, 2002, 09:01 AM   #2
Steve Hartman
Board Regular
 
Steve Hartman's Avatar
 
Join Date: Feb 2002
Location: Houston,Texas
Posts: 418
Default

TOOLS > OPTIONS On the view tab check Window options formulas box
Steve Hartman is offline   Reply With Quote
Old Mar 6th, 2002, 09:04 AM   #3
Scott in Phoenix
New Member
 
Join Date: Mar 2002
Location: Arizona
Posts: 12
Default

Thanks, Steve.

Yes, it's true this will do what I'm looking to do. But I really thought there was some kind of function that would do this for me! It would be a whole lot slicker to put a conditional format that BOLDS the text version and leaves the formula version unbold...

??
Scott in Phoenix is offline   Reply With Quote
Old Mar 6th, 2002, 09:14 AM   #4
IML
MrExcel MVP
 
Join Date: Feb 2002
Location: Denver, CO
Posts: 1,744
Default

still not exactly what your after, but you could highlight your sheet and select goto under the edit menu, select special and the constants radio dial. Now hit bold.


__________________
Give $3 to Mr Excel's Holiday Charity Event!
Write Up
http://www.mrexcel.com/board/viewtop...0916&forum=9&4
Dontate
http://www.mrexcel.com/sunshop/index...bstart=0&id=18
IML is offline   Reply With Quote
Old Mar 6th, 2002, 09:18 AM   #5
Matanuska
New Member
 
Join Date: Feb 2002
Location: Houston, Texas
Posts: 28
Default

Try looking at the text string returned by the Formula property of the VBA Range object referring to the cell:

stringToLookAt = Range("A1").Formula

If cell A1 contains a formula the string returned will contain an "=". If it contains just text it won't.
Matanuska is offline   Reply With Quote
Old Mar 6th, 2002, 09:38 AM   #6
Scott in Phoenix
New Member
 
Join Date: Mar 2002
Location: Arizona
Posts: 12
Default

Matanuska -

What you posted has to be done in VB, right? Not something I can put in the Conditional Formatting dialog box, is it?

Just double-checking...

Doesn't it seem like there should be a function that returns what the actual cell contains??
Scott in Phoenix is offline   Reply With Quote
Old Mar 6th, 2002, 09:40 AM   #7
Matanuska
New Member
 
Join Date: Feb 2002
Location: Houston, Texas
Posts: 28
Default

You can create a custom function in VBA very easily to do this:

Function CellType(cellRef As Range) As String

If Left(cellRef.Formula, 1) = "=" Then
CellType = "Formula"
Else
CellType = "TextOrNumber"
End If

End Function
Matanuska is offline   Reply With Quote
Old Mar 6th, 2002, 09:54 AM   #8
Paul-Johnson
New Member
 
Join Date: Feb 2002
Posts: 47
Default

Another quick check is [ctrl]+ ~

This shows either the formula or the value depending on which is entered.
Paul-Johnson is offline   Reply With Quote
Old Mar 6th, 2002, 10:10 AM   #9
Drew
Board Regular
 
Join Date: Feb 2002
Location: Boston, Mass
Posts: 169
Default

You could try Juan Pablo's tip (from "Tip of the Day" December 18, 2001

Select A1.
Go to Insert, Names, Define.
Put a name in it, like HasForm
in the refers to put:
=GET.CELL(48,A1)

Now, select the range you want to "check" for formulas. Select Conditional Formatting, change "Value is" to "Formula is" and put in this formula
=HasForm
Click on the Pattern button and select something that makes it easy for you to see the click OK.

HTH,
Drew
Drew is offline   Reply With Quote
Old Mar 6th, 2002, 10:41 AM   #10
Guest
 
Posts: n/a
Default

Hey guys!

Thanks for all the great suggestions. Tried the nifty idea using the named ranges, but that limits me to 7 non-contiguous cells for the name, so I'd hafta have lots of different names...

IML - almost missed your idea. I always forget about the cool stuff you can do with Go to > Special...

I'm still hoping to figure out some slick way to do this... But for now, I think IML's idea will suffice. Not quite as slick as what I hoped for, but it works!

Thanks again, everybody. And if anyone comes up with a SLICK way to do this, post it! (You might also drop me an email so I know to take a look. Prolly won't check again for a while...)

Regards,

Scott
  Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 10:31 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
All contents Copyright 1998-2012 by MrExcel Consulting.
diabetic desserts recipes recipes Diabetic Soups Holiday Pizza Recipes Popcorn Recipes Recipes For Microwave Pasta Recipes Casserole Recipes Chili Recipes Curry Recipes Crockpot Recipes Apples Recipes Bread Recipes Vegetarian Recipes Vegetable recipes Desserts Recipes Appetizers Ethnic Recipes Meat Dishes Barbecue Recipes Sauces Recipes Marinade Recipes Low Fat Recipes Frugal Gourmet Kitchen Classics Recipes On The Grill Cook Books Seafood Recipes Cajun Recipes Breads Low Fat Low Fat Breads Bread Machine Recipes Yeast Breads Quick Breads Fat Free Vegetarian Salad Recipes Eggplant Recipes Radish Recipes Tomato Recipes Jalapeno Recipes Potato Recipes Lettuce Recipes Cabbage Recipes Beans Ambrosia Recipes Biscotti Recipes Desserts Low Fat Cookie Recipes Cheesecake Recipes Cake Recipes Pie Recipes Muffin Recipes Custard Recipes Best Appetizers Appetizers Low Fat Salsa Recipes Dip Recipes International Recipes Afghan Recipes Alaska Recipes French Recipes German Recipes Greek Recipes Italian Recipes Spanish Recipes Thai Recipes Korean Recipes Chinese Recipes Mexican Recipes Indian Recipes Beef Recipes Pork Pork & Ham Pork Butts Pork Chop Recipes Pork Ribs Rulled Pork Poultry Recipes Stews Recipes Ground Beef Barbecue Grill Barbecue Smoker All Purpose Sauce BBQ Sauce Barbecue Sauce Carolina BBQ Sauce Pickle Recipes Marinades Smoking Low Fat Appetizers & Dips Low Fat Breakfast Low Fat Cakes Low Fat Cheesecakes Low Fat Cookies Low Fat Desserts Low Fat Fish & Seafood Low Fat Meats Low Fat Pasta Low Fat Pies Low Fat Salads Low Fat Sandwiches Low Fat Sauces & Condiments Low Fat Sides Low Fat Soups Low Fat Vegetarian Baker's Dozen Taste of Home Recipe Book Bon Appetit Cookbook Blacktie Cookbook Buster Cook Book Cookbook USA Cook Book Cook Book Sara's Cookbook Sara's Cookbook Appetizers and Dips Poultry recipes Diabetic recipes Holiday recipes Miscellaneous recipes 110 recipes 1986 Usenet cookbook 2900 recipes Cyberrealm recipes Great sysops of world Specialty recipes Ceideburg recipes Cheese recipes Chili recipes Fruits recipes Garlic recipes Great chefs of NY Londontowne recipes Raisins recipes Recipes for kids US Food Vegetarian recipes Bread recipes Drinks Meat Dishes Brisket recipes Caribou recipes Chicken recipes Filet mignons recipes Pork recipes Swordfish recipes Turkey recipes Pasta recipes Uncategorized recipes Ethnic recipes Canada recipes English recipes Ethiopia recipes Germany recipes Greece recipes Mexican recipes Philippines recipes Welsh recipes Microwave recipes Soups recipes Vegetable recipes Asparagus recipes Barley recipes Brown rice recipes Lentil recipes Mushrooms recipes Salads recipes Wild rice Desserts recipes Cakes recipes Chocolate recipes Cookies recipes Ice cream recipes