Option Explicit 'ユーザー定義関数 '支給日ソート用構造体 Public Type Sikyu id As Integer Nengappi As Date End Type '---------- 年間日数の計算 ---------- Public Function GetNenkanNisu(ByVal TargetDate As Date) As Integer ' グレゴリオ歴による年間日数の計算 ' 引数”TargetDate”は日付変換可能な文字列 Dim intYear As Integer Dim intMonth As Integer intYear = Year(TargetDate) intMonth = Month(TargetDate) If intMonth > 2 Then If (intYear + 1) Mod 4 = 0 Then If (intYear + 1) Mod 100 = 0 Then If (intYear + 1) Mod 400 = 0 Then GetNenkanNisu = 365 Else GetNenkanNisu = 364 End If Else GetNenkanNisu = 365 End If Else GetNenkanNisu = 364 End If Else If intYear Mod 4 = 0 Then If intYear Mod 100 = 0 Then If intYear Mod 400 = 0 Then GetNenkanNisu = 365 Else GetNenkanNisu = 364 End If Else GetNenkanNisu = 365 End If Else GetNenkanNisu = 364 End If End If End Function Public Function SkipSum(ByVal A As Integer, ByVal B As Integer, ByVal Target As Excel.Range) As Double '指定行おきの合計 '引数:[A]指定行 '引数:[B]余り '引数:[Target]選択セル Dim x As Variant Dim y As Double Dim i As Long i = 1 For Each x In Target If i Mod A = B Then y = y + CDbl(x) i = i + 1 Next SkipSum = y End Function