Home |
Search |
Today's Posts |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
A UDF can only return a value to its cell (and a few other minor actions).
So it cannot format a cell. You could some conditional formatting though. NickHK "augustus" wrote in message ... Hi, I got a user defined function as listed below: Public Function EnteredWeek(rWeekEndDate As Range) As String Dim bTimeSheetDayNow As Byte Dim dEnteredWeekEndDate As Date dEnteredWeekEndDate = CDate(rWeekEndDate.Value) <--Breakpoint bTimeSheetDayNow = CByte(WorksheetFunction.Weekday(dEnteredWeekEndDat e)) If bTimeSheetDayNow < 3 Then EnteredWeek = "CAUTION - The date entered for Wednesday is incorrect" Sheet1.Range("F3:H3").Interior.ColorIndex = 3 Exit Function End If If CDate(rWeekEndDate.Value - 1) = 3 And CDate(rWeekEndDate.Value) = Date Then EnteredWeek = "" rWeekEndDate.Interior.Color = 12632256 End Function My problem is if bTimeSheetDayNow < 3 is TRUE, the code won't execute Sheet1.Range("F3:H3").Interior.ColorIndex = 3 and I will get "#VALUE" on my worksheet. Could someone explain to me why Excel won't execute, but I can excute it inside Immediate Window(at Breakpoint)? The rWeekEndDate is in 31/07/2007 format. Thanks. Augustus |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
user defined functions format | Excel Discussion (Misc queries) | |||
How to set user defined format in VBA | Excel Programming | |||
Custom Format for User Defined Function | Excel Discussion (Misc queries) | |||
User Defined Function: Format Output | Excel Programming | |||
User-defined function with a naming format of =ABC.XYZ. | Excel Programming |