LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 49
Default User Defined function to format

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
user defined functions format df_newtovba Excel Discussion (Misc queries) 3 September 22nd 08 05:17 PM
How to set user defined format in VBA hon123456 Excel Programming 2 September 11th 06 04:39 AM
Custom Format for User Defined Function [email protected] Excel Discussion (Misc queries) 5 August 7th 06 11:27 PM
User Defined Function: Format Output Kenny Excel Programming 5 April 29th 04 11:40 PM
User-defined function with a naming format of =ABC.XYZ. Vipul S. Parekh Excel Programming 1 July 31st 03 02:44 AM


All times are GMT +1. The time now is 09:59 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"