View Single Post
  #5   Report Post  
Old December 16th 04, 07:51 PM
Ron Rosenfeld
 
Posts: n/a
Default

On Wed, 15 Dec 2004 07:55:41 -0600, Rita Palazzi wrote:

Windows XP Professional
Office 2000

I have a formula that produces a sentence based on the value of a cell:

=IF(H18=0,CONCATENATE("Shpt Volume Increased ",TEXT(H18,".0%"),"
Y-O-Y"),CONCATENATE("Shpt Volume Decreased ",(TEXT(-H18,".0%"))," Y-O-Y"))


I want the word "Increased" or the word "Decreased" to be bold in the
resultant cell. Does anyone know the correct way to achieve this?

Thanks in advance for any help you may provide!

Rita Palazzi
Senior Engineer / Global Trade Services
FecEx Express


You need to use VBA to accomplish this.

Depending on your setup, you would probable execute this formula in a VB
worksheet change module. The output from the VB macro would be a string which
would go into the cell. When there is just a string in a cell, and not a
formula, a portion of that string can be bolded.

Here is an example that might get you started. To enter it, right-click on the
worksheet tab, then paste the code below into the window that opens. If you
enter something in H18, you will see the result, with the one word bolded, in
H1.

========================
Private Sub Worksheet_Change(ByVal Target As Range)
Dim c As Range, Chg As Range
Dim res As String 'Result will be stored here

Set c = [H1] 'This is where the result will be
Set Chg = [H18] 'Cell to be tested

If Intersect(Target, Chg) Is Nothing Then Exit Sub

res = "Shpt Volume "
Select Case Chg
Case Is 0
res = res & "Increased "
Case Is < 0
res = res & "Decreased "
Case Else
res = res & "Unchanged "
End Select

res = res & Application.WorksheetFunction.Text(Chg, ".0%;.0%;;") & " Y-O-Y"

With c
.Value = res
.Characters(13, 9).Font.Bold = True
End With
===========================

--ron