Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 120
Default How to change color within string?

Definitely you cannot. But to be positive, there use to be sometimes some
roundabouts. In your simplest case you can make a fake function by means of a
worksheet events procedure in VBA. Try it on an example in a new workbook.
From a worksheet open the project (Alt-F11) and from the Projects window
select MicrosoftExcelObjects and your Worksheet name. By doubleclick open the
codemodule window and paste the following example. For Excel 7 the procedure
has been somewhat changed.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim A As Range, S As String
Set A = Range("A:A")
If Not Intersect(Target, A) Is Nothing Then
If Target.Value 0 Then S = "AAAAAA" Else S = "BBBBBB"
With Target.Offset(0, 1)
.Value = S
.Characters(Start:=4, Length:=3).Font.ColorIndex = 3
End With
End If
End Sub

Depending on the change in the first column you will get formatted contents
of the adjacent cells.
I hope you can tailor the example to your needs as soon as you will learn
more about events.

--
Petr Bezucha


"Eric" wrote:

Does anyone have any suggestions on how to change color within string?
For example, in cell B1, if(A1=1,"O-F-O-F","O-N-O-N"), I would like to the
last 3 chars into red color, such as O-F and O-N
Does anyone have any suggestions?
Thanks in advance for any suggestions
Eric

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Checkbox to change background color, font color and remove/ add bo Sara Excel Discussion (Misc queries) 2 May 1st 23 11:43 AM
Change tab color based on current color of a cell MarkT Excel Discussion (Misc queries) 0 May 22nd 08 05:46 PM
Change 3 letter text string to a number string Pete Excel Discussion (Misc queries) 3 December 31st 07 07:47 PM
How to change the default Border, Font Color, and Cell Color Elijah Excel Discussion (Misc queries) 3 November 2nd 05 11:52 PM
Allow users to change the color of the comment indicator color so. DanC Excel Discussion (Misc queries) 1 February 25th 05 05:15 PM


All times are GMT +1. The time now is 12:25 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"