custom function

  • Thread starter Thread starter Steve
  • Start date Start date
S

Steve

i do a lot of comparing cells. my go-to formula is "=c1=c2". Of course I
get a true if they're equal and false otherwise. If I have a lot of cells I
sometimes add conditional formatting that colors the cells false red.

Now my question...maybe I could create a custom function in my personal.xls
workbook that does the compare and the conditional formatting in a single
step. Is something like this worth pursuing?
 
Put this UDF in a REGULAR module. In the cell =cif(a1,b1)

Function cif(x, y)
If x = y Then
cif = "Yes"
End If
End Function

Put this macro in the SHEET module of the sheet desired.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target = "Yes" Then Target.Interior.ColorIndex = 35
End Sub
 
Back
Top