custom function

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?
 
D

Don Guillett

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
 

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