Compare sheets

C

carlos_ray86

I have two sheets and they both have data in them. I'm trying to
compare them and if they are the same then turn the font red. I tried
this but nothing happens.

Dim sht1 As Worksheet, sht2 As Worksheet

Set sht1 = Worksheets("Sheet1")
Set sht2 = Worksheets("Ctg Sheet")

If sht1.Range("f2") = sht2.Range("f22") Then
sht1.Range("F2").Font.Color = 3

End
 
G

Gary Keramidas

try this

Sub test()
Dim sht1 As Worksheet, sht2 As Worksheet

Set sht1 = Worksheets("Sheet1")
Set sht2 = Worksheets("Ctg Sheet")

If sht1.Range("f2") = sht2.Range("f22") Then
sht1.Range("F2").Font.ColorIndex = 3

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