Change font size based on value of a cell

M

MichaelRLanier

If the value of A1>0, I need the font size in a merged cell to change
from the default 10 to 16. It needs to return to the default size
when A1 returns to a value of 0. Can someone help with this?
Thanks.

Michael
 
F

FSt1

hi
sounds like conditional formating but unfortunately with conditional
fomating you can change the color, style, strick through and underline but
not font or font size so it looks like you're stuck with a macro.
you didn't say where your merged cells were so for test i merged B3 with B4.
change to suit.
Private Sub Worksheet_Change(ByVal Target As Range)
Set Target = Range("A1")
If Target > 0 Then
Range("B3").Font.Size = 16
Else
Range("B3").Font.Size = 10
End If
End Sub

so each time the value of A1 changes, the font size will change accordingly.

this is worksheet code so right click the sheet tab, click view code then
paste the above in.

Regards
FSt1
 
S

Susan

this is a worksheet_change macro, which needs to be placed in the
worksheet code area where the action is taking place.
============================
Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)

Set Target = ActiveSheet.Range("a1")

If Target > 0 Then
With ActiveSheet.Range("c1:d1").Font
.Name = "Arial"
.Size = 16
End With
Else
With ActiveSheet.Range("c1:d1").Font
.Name = "Arial"
.Size = 10
End With
End If

End Sub
===========================
i didn't know your "default" size, so i chose "10".
c1:d1 is the merged cell.
hope this helps!
:)
susan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top