+ Reply to Thread
Results 1 to 2 of 2

Change font type in Conditional Formatting

  1. #1
    Kyndsberg
    Guest

    Change font type in Conditional Formatting

    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/micros...e7e6c4230d084a

    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


  2. #2
    Dave Peterson
    Guest

    Re: Change font type in Conditional Formatting

    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

    Kyndsberg wrote:
    >
    > 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/micros...e7e6c4230d084a
    >
    > 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


    --

    Dave Peterson

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1