Results 1 to 8 of 8

Thread: Font Selection Based on Variable
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    New Member TheRogue's Avatar
    Join Date
    Aug 2019
    Location
    Sarasota, FL
    Posts
    23
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Font Selection Based on Variable

    I have a Toggle Button, linked to C1, which returns a TRUE/FALSE.
    What I want to do is change the font formatting of a , based upon the result in C1
    If C1=FALSE, then displays in the default font (Arial, 10), but
    If C1=TRUE, the displays in (Times Roman, 12)

    I thought that this could easily but w/ Conditional Formatting, but apparently I am mistaken.

  2. #2
    MrExcel MVP
    Moderator
    Fluff's Avatar
    Join Date
    Jun 2014
    Location
    Chippenham
    Posts
    28,012
    Post Thanks / Like
    Mentioned
    467 Post(s)
    Tagged
    47 Thread(s)

    Default Re: Font Selection Based on Variable

    You will need a macro do that, do you want to change the format of a cell?
    - Posting Data try one of these tools
    - Posting guidelines, forum rules and terms of use
    - Read the FAQs

    Running Office 365 on Win 10

  3. #3
    Board Regular kweaver's Avatar
    Join Date
    May 2018
    Location
    La Jolla, CA
    Posts
    629
    Post Thanks / Like
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Font Selection Based on Variable

    Since CF doesn't allow you to change the font type,
    you'd have to do something like this (which, of course, Fluff or someone more VBA experienced will simplify, but this is the general idea):

    Code:
    Sub ChgFont()
    If Range("C1") = True Then
     Range("A1:A10").Font.Name = "Times Roman"
     Range("A1:A10").Font.Size = "12"
     Else
     Range("A1:A10").Font.Name = "Arial"
     Range("A1:A10").Font.Size = "10"
     End If
    End Sub

  4. #4
    MrExcel MVP
    Moderator
    Fluff's Avatar
    Join Date
    Jun 2014
    Location
    Chippenham
    Posts
    28,012
    Post Thanks / Like
    Mentioned
    467 Post(s)
    Tagged
    47 Thread(s)

    Default Re: Font Selection Based on Variable

    I was thinking of putting the code in the Click event, like
    Code:
    Private Sub ToggleButton1_Click()
       With Range("D4").Font
          .Name = IIf(Me.ToggleButton1, "Times Roman", "Arial")
          .Size = IIf(Me.ToggleButton1, 12, 10)
       End With
    End Sub
    - Posting Data try one of these tools
    - Posting guidelines, forum rules and terms of use
    - Read the FAQs

    Running Office 365 on Win 10

  5. #5
    New Member TheRogue's Avatar
    Join Date
    Aug 2019
    Location
    Sarasota, FL
    Posts
    23
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Font Selection Based on Variable

    I like that! [In your Example] D4 would be the range of data that i want to effect?

  6. #6
    MrExcel MVP
    Moderator
    Fluff's Avatar
    Join Date
    Jun 2014
    Location
    Chippenham
    Posts
    28,012
    Post Thanks / Like
    Mentioned
    467 Post(s)
    Tagged
    47 Thread(s)

    Default Re: Font Selection Based on Variable

    That's right, just change it to whatever range you need.
    - Posting Data try one of these tools
    - Posting guidelines, forum rules and terms of use
    - Read the FAQs

    Running Office 365 on Win 10

  7. #7
    New Member TheRogue's Avatar
    Join Date
    Aug 2019
    Location
    Sarasota, FL
    Posts
    23
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Font Selection Based on Variable

    Thank You!

  8. #8
    MrExcel MVP
    Moderator
    Fluff's Avatar
    Join Date
    Jun 2014
    Location
    Chippenham
    Posts
    28,012
    Post Thanks / Like
    Mentioned
    467 Post(s)
    Tagged
    47 Thread(s)

    Default Re: Font Selection Based on Variable

    You're welcome & thanks for the feedback
    - Posting Data try one of these tools
    - Posting guidelines, forum rules and terms of use
    - Read the FAQs

    Running Office 365 on Win 10

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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