Thread: Font Color
View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.misc
[email protected] riccifs@tin.it is offline
external usenet poster
 
Posts: 37
Default Font Color

On Jan 6, 6:07 pm, "Chip Pearson" wrote:
You very definitely want to avoid messing with the formulas. You can use the
HasFormula property of a Range to see if there is a formula and get out if
there is one. Also, you probably want to exit if Target has more than one
cell:

If Target.Cells.Count 1 Then
Exit Sub
End If

If Target.HasFormula = True Then
Exit Sub
End If

--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consultingwww.cpearson.com
(email on the web site)

wrote in message

...

On Jan 5, 7:14 am, Carim wrote:
Hi,


It cannot be done with formulas but with VBA :


Private Sub Worksheet_Change(ByVal Target As Range)
Set Target = Range("A1")
WithTarget.Characters(Start:=1, Length:=4).Font
.ColorIndex = 3
End With
WithTarget.Characters(Start:=5, Length:=12).Font
.ColorIndex = 5
End With
End Sub


HTH


Hi Carim,
I'm using your code and it works great for a cell with a text but if
there is in it mixed text and formula it does not seem to work.
What I'm doing wrong?


Bye, Stefano.


Sorry, I'm not sure to understand what I have to do. Where I need to
insert the two If statement?