■ 最大日数取得(GetMaxDay)

DateValue関数とFormat関数のみを使用して閏年の面倒な判定を行わずに指定年月の最大日を取得できます
引数は年月がString("200010"など)、戻り値もStringとなっていますが、一部の修正で簡単に修正できます

'******************************************************************************
'*  関数名:最大日数取得(GetMaxDay)
'*  引 数:年月日(ByVal w_ymdstr As String)
'*  戻り値:最大日数(String)
'*  機 能:指定した年月の月末日を取得する
'******************************************************************************
Private Function GetMaxDay(ByVal w_ymdstr As String) As String

    ' 12月の場合
    If Mid(w_ymdstr, 6, 2) = "12" Then
        ' 1月1日の前日の日をセット
        GetMaxDay = Format(DateValue(Format(Val(Mid(w_ymdstr, 1, 4)) + 1) & _
                "/01/01") - 1, "dd")
    Else
        ' 翌月1日の前日の日をセット
        GetMaxDay = Format(DateValue(Mid(w_ymdstr, 1, 5) & Format(Val(Mid( _
                w_ymdstr, 6, 2)) + 1) & "/01") - 1, "dd")
    End If

End Function