Change Font Color

memartin

New Member
Joined
Oct 28, 2010
Messages
6
I want to change the font color from the default (black) to red for part of a result within a cell.
For example, the formula ="The current version date is: "&right(Tab1!$A$13,9) produces "The current version date is: 6/20/12" all in black.
But I want it to produce "The current version date is: 6/20/12". Any suggestions?
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
If it's practical for your application, you could place the string "The current version date is: " in one cell and place the formula in the cell directly adjacent to it, formatted in red.
 
Upvote 0
only option would be to have "The current version date is: " and "6/20/12" in different cells

Another option would be to remove the formula and fill the cell from VB event code...

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
  Const OutputSheet As String = "Sheet2"
  Const OutputCell As String = "B2"
  If Target.Address(0, 0) = "A13" Then
    With Worksheets(OutputSheet).Range(OutputCell)
      .Value = "The current version date is: " & Right(Target.Value, 9)
      .Characters(30, 9).Font.ColorIndex = 3
    End With
  End If
End Sub

HOW TO INSTALL Event Code
------------------------------------
If you are new to event code procedures, they are easy to install. To install it, right-click the name tab at the bottom of the worksheet that is to have the functionality to be provided by the event code and select "View Code" from the popup menu that appears. This will open up the code window for that worksheet. Copy/Paste the event code into that code window. That's it... the code will now operate automatically when its particular event procedure is raised by an action you take on the worksheet itself.
 
Upvote 0
Another option would be to remove the formula and fill the cell from VB event code...

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
  Const OutputSheet As String = "Sheet2"
  Const OutputCell As String = "B2"
  If Target.Address(0, 0) = "A13" Then
    With Worksheets(OutputSheet).Range(OutputCell)
      .Value = "The current version date is: " & Right(Target.Value, 9)
      .Characters(30, 9).Font.ColorIndex = 3
    End With
  End If
End Sub

HOW TO INSTALL Event Code
------------------------------------
If you are new to event code procedures, they are easy to install. To install it, right-click the name tab at the bottom of the worksheet that is to have the functionality to be provided by the event code and select "View Code" from the popup menu that appears. This will open up the code window for that worksheet. Copy/Paste the event code into that code window. That's it... the code will now operate automatically when its particular event procedure is raised by an action you take on the worksheet itself.

This a great solution. I will try it. Thank you very much.
 
Upvote 0

Forum statistics

Threads
1,214,592
Messages
6,120,433
Members
448,961
Latest member
nzskater

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top