Font Selection Based on Variable

TheRogue

New Member
Joined
Aug 3, 2019
Messages
23
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 <Text Range>, based upon the result in C1
If C1=FALSE, then <Text Range> displays in the default font (Arial, 10), but
If C1=TRUE, the <Text Range> displays in (Times Roman, 12)

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

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
You will need a macro do that, do you want to change the format of a cell?
 
Upvote 0
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
 
Upvote 0
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
 
Upvote 0
That's right, just change it to whatever range you need.
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,213,521
Messages
6,114,109
Members
448,548
Latest member
harryls

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