Creating Functions

  • Thread starter Thread starter Lynxbci3
  • Start date Start date
L

Lynxbci3

Hello

Can you utilise excel functions within your own user defined fucntion
?

My function (BWK) takes a date fromat 1040801 converts it to 01/08/0
then
i would like to use weeknum to give the week for this date.

So the function BWK(1040801) is giving me 31 on the spreadsheet

I tried

Function BWK(AS400 As String)

ldate = Len(AS400)

If ldate = 7 Then
AS400Day = Mid(AS400, 6, 2)
AS400Month = Mid(AS400, 4, 2)
AS400Year = Mid(AS400, 2, 2)
Else
AS400Day = Mid(AS400, 8, 2)
AS400Month = Mid(AS400, 5, 2)
AS400Year = Mid(AS400, 2, 2)
End If

DateConvert = AS400Day & "/" & AS400Month & "/" & AS400Year

BWK = WEEKNUM(DateConvert)

End Function

BUT WEEKNUM won't work within this function. I could use a calculatio
to work out the week number but it seems futile, ehwn there is
function set up.

Thank
 
....
BWK = Application.WorksheetFunction.WEEKNUM(DateConvert)
....

Regards,
sulprobil
 

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

Back
Top