Change size of font if cell value is greater than 0

M

mrlanier

I would like to change the size of font in a merged cell when the
value of a different cell is greater than 0. For example, if A1>0,
then the font in B1 (merged cells B1:D1) will change from a default of
8 to 12, and revert back to 8 when A1=0. Are there any suggestions
for a macro. Thanks in advance.

Michael
 
O

Otto Moehrbach

This little macro will do that. This is a sheet event macro and must be
placed in the sheet module of the sheet in question. As written, it will
change the font size of B1 to 12 if A1 is greater than 0, and it will change
it to 8 if A1 is anything else. HTH Otto
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
If Target.Value = "" Then Exit Sub
If Not Intersect(Target, Range("A1")) Is Nothing Then
If Range("A1").Value > 0 Then
Range("B1").Font.Size = 12
Else
Range("B1").Font.Size = 8
End If
End If
End Sub
 

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