您现在的位置是:首页 > Excel技巧>Excel日历

Excel表格日历模板-Excel日历

发布于2022-04-150人已围观

Excel设计的日历。打开显示当前的时间和本年的日历。通过上下两个按钮可以切换年份。按下为递减一年,按上显示增加一年的日历。周末显示为红色哦。


作者:Excel小子-Office中国

 

Excel日历操作动画

Excel表格日历模板

 


  Excel日历详细VBA代码:               

    

        Private Sub SpinButton1_Change()

            Cells(1, 2) = SpinButton1.Value

        End Sub        

        Private Sub SpinButton2_Change()

            Cells(1, 5) = SpinButton2.Value

        End Sub

                   

        Sub newti()      

            newtime

        End Sub

        Sub riqi()

        Application.EnableEvents = False

            Dim arr()

            Dim i

            Dim t

            Dim ar, a

            Dim x, y, j

            Dim first_day_weekday

            Dim last_day

            'arr = Range("a3:g8")

            For y = 1 To 4

                For x = 1 To 3

                j = j + 1

            first_day_weekday = Weekday(DateSerial([b1], j, 1), vbSunday)

            last_day = Day(DateSerial([b1], j + 1, 0))

            'Debug.Print DateSerial([b1], [e1] + 1, 0)

            'Stop

            ReDim arr(1 To 6, 1 To 7)

            For i = 1 To 6

                For t = 1 To 7

                    ar = ar + 1

                    

                    If first_day_weekday <= ar Then

                    a = a + 1

                    If a <= last_day Then

                    'Stop

                    arr(i, t) = a

                    Else

                    arr(i, t) = ""

                    End If

                    End If

                Next t

            Next i

            'Stop

            Cells((y - 1) * 9 + 4, (x - 1) * 8 + 1).Resize(6, 7) = arr

            a = 0

            ar = 0

            Next x

            Next y

        Application.EnableEvents = True

        End Sub


        模块函数:

        Sub newtime()

        Calculate

        Application.OnTime Now + TimeValue("00:00:01"), "newtime"

        End Sub


点击加入群:OFFICE3658 结识Excel大神
学好Excel,效率成倍提高,薪水稳步增长,职位快速提升
每天一个源创技巧,如觉得有用,请点上面 关注。更重要手机转发分享


如喜欢此技巧,手机右上角点开,分享到QQ空间,方便自己以后看



相关文章

文章评论

表情

共0条评论
  • 这篇文章还没有收到评论,赶紧来抢沙发吧~

标签云

站长特荐