Where's the bug?

J

Jim May

with 3/15/04 (formated date) in Cell B5
and =Spdate(B5) in D5 -- results -->> #VALUE! 'Help

Function SpDate(MyDate As Date) As String
Dim MYr As String
Dim MWk As String
Dim MDy As String
MYr = Year(MyDate)
MWk = Round((MyDate - DateSerial(Year(MyDate), 1, 1)) / 7, 0)
MDy = Day(MyDate)
SpDate = "MYr&" / "&MWk&" / "&MDy"
End Function
 
B

Bob Phillips

You are treating it like worksheet functions Jim.

The last line should not be in quotes

Function SpDate(MyDate As Date) As String
Dim MYr As String
Dim MWk As String
Dim MDy As String
MYr = Year(MyDate)
MWk = Round((MyDate - DateSerial(Year(MyDate), 1, 1)) / 7, 0)
MDy = Day(MyDate)
SpDate = MYr & " / " & MWk & " / " & MDy
End Function


--

HTH

RP
(remove nothere from the email address if mailing direct)
 

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

Similar Threads

Month problem 4
Workbook reminder 0
Access VBA to format Excel 1
Printing issue 1
VB Printing problem 0
Convert Julian to Date 1
Pop message last businessday of month 3
Select Case 8

Top