Conditional font size

DaKen

Board Regular
Joined
Feb 18, 2002
Messages
55
Is it possible to change font size in a cell based on a criteria. I'm trying to make cells that contain a formula appear in a larger font size.

Thanks!!!
Doug
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Right click on your sheet tab, left click on View Code, and paste this in. Modify for font size. The error trap is for the occasions when no formulas exist on the sheet.

Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
Cells.SpecialCells(xlCellTypeFormulas, 23).Font.Size = 24
End Sub

Tom Urtis
 
Upvote 0
I think you would have to "reset" all cells font size, before changing the cells with formulas, like this

Cells.Font.Size = 12

and then do what Tom suggested:

Cells.SpecialCells(xlCellTypeFormulas, 23).Font.Size = 24
 
Upvote 0
Do you mean like this ?

<pre>
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Rng as Range
Set Rng = Range("A1:B20")
If Not Intersect(Target,Rng) is Nothing then
On Error Resume Next
Rng.Font.Size = 12
Rng.SpecialCells(xlCellTypeFormulas, 23).Font.Size = 24
End If
End Sub
</pre>
 
Upvote 0
Perfect! If it's not too much to ask, can I also format color and bold/italic? Also center in the cell?
This message was edited by DaKen on 2002-02-21 06:00
 
Upvote 0
You can use the macro recorder to get the appropiate commands

<pre>
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Rng as Range
Set Rng = Range("A1:B20")
If Not Intersect(Target,Rng) is Nothing then
On Error Resume Next
With Rng.Font
.Size = 12
.Bold = False
.ColorIndex = -4105
End With
Rng.HorizontalAlignment = xlGeneral
With Rng.SpecialCells(xlCellTypeFormulas, 23).Font
.Size = 24
.Bold = True
.ColorIndex = 3
End With
Rng.SpecialCells(xlCellTypeFormulas, 23).HorizontalAlignment = xlCenter
End If
End Sub
</pre>
 
Upvote 0
Thanks again for your patience and help. I really appreciate the opportunity to access this type of forum!

Doug
 
Upvote 0

Forum statistics

Threads
1,223,293
Messages
6,171,265
Members
452,391
Latest member
BHG

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