ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   custom function (https://www.excelbanter.com/excel-discussion-misc-queries/220710-custom-function.html)

Steve

custom function
 
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?

Don Guillett

custom function
 

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

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Steve" wrote in message
...
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?




All times are GMT +1. The time now is 02:39 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com