Change font type in Conditional Formatting

  • Thread starter Thread starter Kyndsberg
  • Start date Start date
K

Kyndsberg

I am trying to chance the font type with Conditional Formatting but I
can't. So I've searched a bit in this newsgroup and found out, that
it isn't possible.

(Google link to message:)
http://groups.google.dk/group/micro...+Formatting+font+type&rnum=1#08e7e6c4230d084a

Can anyone help me with a workaround in VBA or something similar? I
guess someone else must have had a simular problem.

(I don't know any VBA, so an explanation would be appreciated.)

Thank you

/Kasper
 
It depends on how that cell changes.

If it's the result of typing, you can use the worksheet_change event.

If it's the result of a calculation, you can use the worksheet_calculate event.

I'm gonna use the typing change in this sample:

rightclick on the worksheet tab that should have this behavior. Select view
code and paste this in the codewindow:

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)

Dim myFont As String

'one cell at a time
If Target.Cells.Count > 1 Then Exit Sub

'only in column A
If Intersect(Target, Me.Range("a:a")) Is Nothing Then Exit Sub

myFont = "Arial"
Select Case LCase(Target.Value)
Case Is = "hi there": myFont = "Script"
Case Is = "ok": myFont = "Times New Roman"
End Select

Target.Font.Name = myFont

End Sub

I check for a single cell changing--and it has to be in column A.

If the lower case value is "hi there", the font will change to Script. It the
lower case value is "ok", then I use times new roman.

If it's something else, I use Arial.

Now back to that worksheet and type some things in column A.

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

If you want to read more about these kinds of events:

Chip Pearson's site:
http://www.cpearson.com/excel/events.htm

David McRitchie's site:
http://www.mvps.org/dmcritchie/excel/event.htm
 
Back
Top