I am new to vb and excel but I have to develop a custom udf for excel. I have read I have tried to alter my code below many times with the suggestions on this forum to no avail. What am I missing. This code is for working out a Julian date in integer form.
Option Explicit
Function CUSTOMJULIAN(JYear As Integer, JMonth As Integer, JDay As Integer) As Integer
Application.Volatile
Dim iyear As Integer
iyear = JYear
Dim imonth As Integer
imonth = JMonth + 1
If imonth <= 2 Then
iyear = iyear - 1
imonth = imonth + 12
End If
CUSTOMJULIAN = Int(365.25 * iyear) + Int(30.6001 * imonth) + JDay + 1720995
If JDay + (31 * (JMonth + 12 * JYear)) >= (15 + (31 * (10 + 12 * 1582))) Then
Dim iadjustment As Integer
iadjustment = Int(0.01 * iyear)
CUSTOMJULIAN = CUSTOMJULIAN + 2 - iadjustment + Int(0.25 * iadjustment)
End If
End Function