VBA 获取当前时间的月份天数
Sub huoquqiqi() Dim g_year As Integer Dim g_month As Integer Dim g_days As Integer g_year = Year(Now) '时间函数,获取当前时间的年份 g_month = Month(Now) If g_month = 2 Then '当二月份时,判断当前年份是否为闰年 If g_year Mod 400 = 0 Or g_year Mod 4 = 0 Then g_days = 29 Else g_days = 28 End If Else Select Case g_month Case 1, 3, 5, 7, 8, 10, 12 g_days = 31 Case 4, 6, 9, 11 g_days = 30 End Select End If Range("c2") = g_year & g_month & g_days