vba to change font size excel 2010

johnny52

Active Member
Joined
Oct 13, 2006
Messages
333
Office Version
  1. 2010
  2. 2007
Platform
  1. Windows
I realize that you can't change the font size with conditional formatting,due to column width changes,
so I was hoping someone could write a quick vba to apply to three columns A,B,C,all rows,and do the following

if cell value is less than 15 ,font size 15.

not good at visual basic.

Thanks
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
I am guessing that all three columns contain differing row lenghts,

If this is not the case then the code can be shorted. (it can probably be done better anyway)

Code:
Sub FourteenOrLess()
Dim i As Long
Dim LastRow1 As Long
Dim lastRow2 As Long
Dim LastRow3 As Long
LastRow1 = Cells(Rows.Count, 1).End(xlUp).Row
lastRow2 = Cells(Rows.Count, 2).End(xlUp).Row
LastRow3 = Cells(Rows.Count, 3).End(xlUp).Row
    For i = 1 To LastRow1
        If Cells(i, 1).Value < 15 Then
            Cells(i, 1).Font.Size = 15
        End If
    Next i
    For i = 1 To lastRow2
        If Cells(i, 2).Value < 15 Then
            Cells(i, 2).Font.Size = 15
        End If
    Next i
    For i = 1 To LastRow3
           If Cells(i, 3).Value < 15 Then
               Cells(i, 3).Font.Size = 15
           End If
    Next i
End Sub
 
Upvote 0
Thanks

It worked just fine............greatly appreciated.
 
Upvote 0

Forum statistics

Threads
1,224,595
Messages
6,179,799
Members
452,943
Latest member
Newbie4296

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