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 Jun 7th, 2004, 01:42 PM   #1
Ragnar78
 
Join Date: Feb 2004
Posts: 210
Default Formatting part of text in Cell

Hy,

I was wondering if it is possible to format a part of text in the same cell, or it is better to cutt the string and put it into multiple cells...
Thanks...

Ps: would the text box be a good solution?
Ragnar78 is offline   Reply With Quote
Old Jun 7th, 2004, 01:52 PM   #2
Glaswegian
 
Glaswegian's Avatar
 
Join Date: Oct 2003
Location: Glasgow, Scotland
Posts: 1,482
Default

You can do it via the Formula Bar, but that may not be very practical if you have a great deal of text in lots of cells. Works fine for a single cell - highlight the text and then format as usual.

Regards
__________________
Iain - XL2002 on Win XP - A Bank is a place that will lend you money if you can prove you don't need it.

Member of ASAP :: Member of UNITE
Glaswegian is offline   Reply With Quote
Old Jun 8th, 2004, 05:52 AM   #3
Ragnar78
 
Join Date: Feb 2004
Posts: 210
Default Re: Formatting part of text in Cell

Hy,

Thx for the reply,

What i want to do is search for a word in diffrent cells, and whenever i find this word i want it to be highlited...
(in a VB code of course)
Ragnar78 is offline   Reply With Quote
Old Jun 8th, 2004, 06:25 AM   #4
HOTPEPPER
MrExcel MVP
 
HOTPEPPER's Avatar
 
Join Date: Mar 2004
Location: Oregon
Posts: 13,278
Default Re: Formatting part of text in Cell

What's the word?
Is there a specific range of cells you are looking to find it in?

It will also need to be straight text, not the result of a formula.
HOTPEPPER is offline   Reply With Quote
Old Jun 8th, 2004, 06:33 AM   #5
Tom Urtis
MrExcel MVP
 
Tom Urtis's Avatar
 
Join Date: Feb 2002
Location: San Francisco, California USA
Posts: 9,626
Default Re: Formatting part of text in Cell

The thing with this sort of request is, there are so many possibilities of what can be the case, it is hard for people who ask for this to pin down what they really want. Consider, assuming you want the word "word" to be highlighted:

- Should it only be "word"?
- What about "Word"?
- What about "WORD"
- Should the "word" portion of "wordy" or "words" only be highlighted? Or ignored because it is part of a bigger word?
- If ignored, then a consideration needs to be made for when / if it is found at the end of a sentence, and abutting a punctuation character, such as "That's the word.", or "Is that the word?"
- What if there is more than one instance of that word in the cell? Highlight all that are found? Only the first instance?

I'm not trying to bedevil you here, just suggesting you consider what you really want, from a one programmer's perspective. Keep in mind this is only possible with constants, not in cells containing formulas.

If you select a range of cells, the following code will set in bold red font the first instance of the word "word" in any form it is found within the selected cells. I'll be off the board until Tuesday afternoon so if this is not all you want, perhaps someone else may assist. Then again, if it is what you want, then hey, cool.


Sub Test1()
Application.ScreenUpdating = False
Dim cell As Range, Txt As String, TxtLen As Integer
Txt = "word"
TxtLen = Len(Txt)
For Each cell In Selection.SpecialCells(2, 3)
With cell
Dim StrLoc As Integer
On Error Resume Next
StrLoc = Application.Search(Left(Txt, Len(Txt)), .Value)
If Err.Number = 0 Then
With .Characters(START:=StrLoc, Length:=TxtLen).Font
.ColorIndex = 3
.Bold = True
End With
Else
Err.Clear
End If
End With
Next cell
Application.ScreenUpdating = True
End Sub
__________________
Tom Urtis
Tom Urtis is offline   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 +1. The time now is 05:33 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
All contents Copyright 1998-2010 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