Formatting Font in a range based on reference range

Patrick3001

New Member
Joined
Oct 28, 2010
Messages
4
Hello all,

I'm sure this is very simple but I'm stuck.

I have a range of cells - L1:L1000 all of which need to have their font changed if the respective cell in T1:T1000 = "Caution".

I've got conditional formatting for background shading, but thats no good for people using black and white printers hence the font change.

So far I'm at:

Private Sub Worksheet_Calculate()
If (Range("T1")) = "Caution" Then
Range("L1").Font.Name = "Impact"
Else
Range("L1").Font.Name = "Calibri"
End If


This seems to work fine for "L1", I just don't know how to make it work through each row up to L1000.

I'm using excel 2010, but file has to also run in 2003.

Any help would be greatly appreciated.

Thanks
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Welcome to the board!

Try;
Code:
Private Sub Worksheet_Calculate()
    Dim rngCell As Range
    
    For Each rngCell In Range("L1:L1000")
        If rngCell.Text = "Caution" Then
            rngCell.Font.Name = "Impact"
        Else
            rngCell.Font.Name = "Calibri"
        End If
    Next rngCell
End Sub
 
Upvote 0
Try

Code:
Private Sub Worksheet_Calculate()
Dim i As Long
For i = 1 To 1000
    If Range("T" & i).Value = "Caution" Then
        Range("L" & i).Font.Name = "Impact"
    Else
        Range("L" & i).Font.Name = "Calibri"
    End If
Next i
End Sub
 
Upvote 0
Try this :

Code:
Sub TestFont()

    For Each c In Range("l1:l30")
        If Range("T" & c.Row) = "Caution" Then
            c.Font.Name = "Impact"
        Else
            c.Font.Name = "Calibri"
        End If
    Next c

End Sub

Success
Erik
 
Upvote 0
Erik, Peter,

Thank you both so much - I've checked, and both of your responses work exactly as requested.

Thank you again.


Patrick
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,849
Members
452,361
Latest member
d3ad3y3

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