ExcelHome技术论坛

 找回密码
 免费注册

QQ登录

只需一步,快速开始

快捷登录

搜索
EH技术汇-专业的职场技能充电站 妙哉!函数段子手趣味讲函数 Excel服务器-会Excel,做管理系统 效率神器,一键搞定繁琐工作
HR薪酬管理数字化实战 Excel 2021函数公式学习大典 Excel数据透视表实战秘技 打造核心竞争力的职场宝典
让更多数据处理,一键完成 数据工作者的案头书 免费直播课集锦 ExcelHome出品 - VBA代码宝免费下载
用ChatGPT与VBA一键搞定Excel WPS表格从入门到精通 Excel VBA经典代码实践指南
楼主: aideng0507

[求助] office 2016没有日历控件,DIY 日历窗体

[复制链接]

TA的精华主题

TA的得分主题

发表于 2019-11-13 10:05 | 显示全部楼层
aideng0507 发表于 2019-11-9 16:47
别沉下去了,帮帮忙啊!有没有高手来指导一下,太难了

用自己注册的日历插件,MSCOMCT2.OCX(网上有下载)
1.gif

test.rar

26.26 KB, 下载次数: 78

TA的精华主题

TA的得分主题

 楼主| 发表于 2019-11-13 11:16 | 显示全部楼层
lss001 发表于 2019-11-13 09:00
日历窗体各个日期控件中加入单击事件,单击事件写入退出与赋值!!!

搞不明白怎么弄,日历窗体代码如下:
Private Sub UserForm_Initialize() 'ComboBox1.Value  '?'ComboBox2.Value  '?
    On Error Resume Next
    WEE = Weekday(ComboBox1.Value & "-" & ComboBox2.Value & "-1", vbSunday)
    If WEE = 1 Then
        dsta = DateSerial(ComboBox1.Value, ComboBox2.Value, 1) - 7
    Else
        dsta = DateSerial(ComboBox1.Value, ComboBox2.Value, 1) - WEE + 1
    End If
   
    rs = 1: cs = 1
    For rs = 1 To 6
        For cs = 1 To 7
            With Me.Controls("d" & rs & cs)
                .Caption = Day(dsta + (rs - 1) * 7 + cs - 1)
                .BackColor = &H8000000F
                .ForeColor = &H0&
                If Weekday(dsta + (rs - 1) * 7 + cs - 1) = 1 Or Weekday(dsta + (rs - 1) * 7 + cs - 1) = 7 Then
                    .ForeColor = &HFF&
                End If
                If rs = 1 And .Caption > 10 Then '??????????
                    .ForeColor = &HC0C0C0
                ElseIf rs >= 5 And .Caption < 15 Then
                    .ForeColor = &HC0C0C0
                End If
                If Day(dsta + (rs - 1) * 7 + cs - 1) = Day(Now()) And Month(dsta + (rs - 1) * 7 + cs - 1) = Month(Now()) Then '??????????
                .BackColor = &HFFFF&
                End If
            End With
        Next
    Next
End Sub
Private Sub SpinButton1_SpinDown()
ComboBox1.Value = ComboBox1.Value - 1
End Sub
Private Sub SpinButton1_SpinUp()
ComboBox1.Value = ComboBox1.Value + 1
End Sub
Private Sub SpinButton2_SpinDown()
If ComboBox2.Value = 1 Then
ComboBox1.Value = ComboBox1.Value - 1
ComboBox2.Value = 12
Else
ComboBox2.Value = ComboBox2.Value - 1
End If
End Sub
Private Sub SpinButton2_SpinUp()
If ComboBox2.Value = 12 Then
ComboBox1.Value = ComboBox1.Value + 1
ComboBox2.Value = 1
Else
ComboBox2.Value = ComboBox2.Value + 1
End If
End Sub
Private Sub ComboBox1_Change()
    UserForm_Initialize
    Label4.Caption = ComboBox1.Value
End Sub
Private Sub ComboBox2_Change()
    UserForm_Initialize
    Label6.Caption = ComboBox2.Value
End Sub
Private Sub CommandButton1_Click()
Unload rili
UserForm1.TextBox1.Value = Format(Date, "yyyy/dd/mm")
    'With ActiveSheet
    'Call lk.lsh(.Name, 1)
   
    dvuu = DateSerial(ComboBox1.Value, ComboBox2.Value + MBUU, DBUU) '???
   
    ActiveCell.Value = DateSerial(ComboBox1.Value, ComboBox2.Value + MBUU, DBUU) + TimeSerial(Hour(Now()), Minute(Now()), Second(Now()))
    'Call lk.lsh(.Name, 2)
    'End With
End Sub
Private Sub d11_Click()
Unload rili
UserForm1.TextBox1.Value = Format(Date, "yyyy/dd/mm")
    DBUU = d11.Caption
    MBUU = IIf(DBUU > 10, -1, 0)
    CommandButton1_Click
End Sub

Private Sub d12_Click()
Unload rili
UserForm1.TextBox1.Value = Format(Date, "yyyy/dd/mm")
    DBUU = d12.Caption
    MBUU = IIf(DBUU > 10, -1, 0)
    CommandButton1_Click
End Sub

Private Sub d13_Click()
Unload rili
UserForm1.TextBox1.Value = Format(Date, "yyyy/dd/mm")
    DBUU = d13.Caption
    MBUU = IIf(DBUU > 10, -1, 0)
    CommandButton1_Click
End Sub

Private Sub d14_Click()
Unload rili
UserForm1.TextBox1.Value = Format(Date, "yyyy/dd/mm")
    DBUU = d14.Caption
    MBUU = IIf(DBUU > 10, -1, 0)
    CommandButton1_Click
End Sub

Private Sub d15_Click()
Unload rili
UserForm1.TextBox1.Value = Format(Date, "yyyy/dd/mm")
    DBUU = d15.Caption
    MBUU = IIf(DBUU > 10, -1, 0)
    CommandButton1_Click
End Sub

Private Sub d16_Click()
Unload rili
UserForm1.TextBox1.Value = Format(Date, "yyyy/dd/mm")
    DBUU = d16.Caption
    MBUU = IIf(DBUU > 10, -1, 0)
    CommandButton1_Click
End Sub

Private Sub d17_Click()
Unload rili
UserForm1.TextBox1.Value = Format(Date, "yyyy/dd/mm")
    DBUU = d17.Caption
    MBUU = IIf(DBUU > 10, -1, 0)
    CommandButton1_Click
End Sub
Private Sub d21_Click()
Unload rili
UserForm1.TextBox1.Value = Format(Date, "yyyy/dd/mm")
    DBUU = d21.Caption
    MBUU = 0
    CommandButton1_Click
End Sub

Private Sub d22_Click()
Unload rili
UserForm1.TextBox1.Value = Format(Date, "yyyy/dd/mm")
    DBUU = d22.Caption
    MBUU = 0
    CommandButton1_Click
End Sub

Private Sub d23_Click()
Unload rili
UserForm1.TextBox1.Value = Format(Date, "yyyy/dd/mm")
    DBUU = d23.Caption
    MBUU = 0
    CommandButton1_Click
End Sub

Private Sub d24_Click()
Unload rili
UserForm1.TextBox1.Value = Format(Date, "yyyy/dd/mm")
    DBUU = d24.Caption
    MBUU = 0
    CommandButton1_Click
End Sub

Private Sub d25_Click()
Unload rili
UserForm1.TextBox1.Value = Format(Date, "yyyy/dd/mm")
    DBUU = d25.Caption
    MBUU = 0
    CommandButton1_Click
End Sub

Private Sub d26_Click()
Unload rili
UserForm1.TextBox1.Value = Format(Date, "yyyy/dd/mm")
    DBUU = d26.Caption
    MBUU = 0
    CommandButton1_Click
End Sub

Private Sub d27_Click()
Unload rili
UserForm1.TextBox1.Value = Format(Date, "yyyy/dd/mm")
    DBUU = d27.Caption
    MBUU = 0
    CommandButton1_Click
End Sub
Private Sub d31_Click()
Unload rili
UserForm1.TextBox1.Value = Format(Date, "yyyy/dd/mm")
    DBUU = d31.Caption
    MBUU = 0
    CommandButton1_Click
End Sub

Private Sub d32_Click()
Unload rili
UserForm1.TextBox1.Value = Format(Date, "yyyy/dd/mm")
    DBUU = d32.Caption
    MBUU = 0
    CommandButton1_Click
End Sub

TA的精华主题

TA的得分主题

 楼主| 发表于 2019-11-13 11:17 | 显示全部楼层
aideng0507 发表于 2019-11-13 11:16
搞不明白怎么弄,日历窗体代码如下:
Private Sub UserForm_Initialize() 'ComboBox1.Value  '?'ComboBo ...

Private Sub d33_Click()
Unload rili
UserForm1.TextBox1.Value = Format(Date, "yyyy/dd/mm")
    DBUU = d33.Caption
    MBUU = 0
    CommandButton1_Click
End Sub

Private Sub d34_Click()
Unload rili
UserForm1.TextBox1.Value = Format(Date, "yyyy/dd/mm")
    DBUU = d34.Caption
    MBUU = 0
    CommandButton1_Click
End Sub

Private Sub d35_Click()
Unload rili
UserForm1.TextBox1.Value = Format(Date, "yyyy/dd/mm")
    DBUU = d35.Caption
    MBUU = 0
    CommandButton1_Click
End Sub

Private Sub d36_Click()
Unload rili
UserForm1.TextBox1.Value = Format(Date, "yyyy/dd/mm")
    DBUU = d36.Caption
    MBUU = 0
    CommandButton1_Click
End Sub

Private Sub d37_Click()
Unload rili
UserForm1.TextBox1.Value = Format(Date, "yyyy/dd/mm")
    DBUU = d37.Caption
    MBUU = 0
    CommandButton1_Click
End Sub
Private Sub d41_Click()
Unload rili
UserForm1.TextBox1.Value = Format(Date, "yyyy/dd/mm")
    DBUU = d41.Caption
    MBUU = 0
    CommandButton1_Click
End Sub

Private Sub d42_Click()
Unload rili
UserForm1.TextBox1.Value = Format(Date, "yyyy/dd/mm")
    DBUU = d42.Caption
    MBUU = 0
    CommandButton1_Click
End Sub

Private Sub d43_Click()
Unload rili
UserForm1.TextBox1.Value = Format(Date, "yyyy/dd/mm")
    DBUU = d43.Caption
    MBUU = 0
    CommandButton1_Click
End Sub

Private Sub d44_Click()
Unload rili
UserForm1.TextBox1.Value = Format(Date, "yyyy/dd/mm")
    DBUU = d44.Caption
    MBUU = 0
    CommandButton1_Click
End Sub

Private Sub d45_Click()
Unload rili
UserForm1.TextBox1.Value = Format(Date, "yyyy/dd/mm")
    DBUU = d45.Caption
    MBUU = 0
    CommandButton1_Click
End Sub

Private Sub d46_Click()
Unload rili
UserForm1.TextBox1.Value = Format(Date, "yyyy/dd/mm")
    DBUU = d46.Caption
    MBUU = 0
    CommandButton1_Click
End Sub

Private Sub d47_Click()
Unload rili
UserForm1.TextBox1.Value = Format(Date, "yyyy/dd/mm")
    DBUU = d47.Caption
    MBUU = 0
    CommandButton1_Click
End Sub
Private Sub d51_Click()
Unload rili
UserForm1.TextBox1.Value = Format(Date, "yyyy/dd/mm")
    DBUU = d51.Caption
    MBUU = IIf(DBUU < 15, 1, 0)
    CommandButton1_Click
End Sub

Private Sub d52_Click()
Unload rili
UserForm1.TextBox1.Value = Format(Date, "yyyy/dd/mm")
    DBUU = d52.Caption
    MBUU = IIf(DBUU < 15, 1, 0)
    CommandButton1_Click
End Sub

Private Sub d53_Click()
Unload rili
UserForm1.TextBox1.Value = Format(Date, "yyyy/dd/mm")
    DBUU = d53.Caption
    MBUU = IIf(DBUU < 15, 1, 0)
    CommandButton1_Click
End Sub

Private Sub d54_Click()
Unload rili
UserForm1.TextBox1.Value = Format(Date, "yyyy/dd/mm")
    DBUU = d54.Caption
    MBUU = IIf(DBUU < 15, 1, 0)
    CommandButton1_Click
End Sub

Private Sub d55_Click()
Unload rili
UserForm1.TextBox1.Value = Format(Date, "yyyy/dd/mm")
    DBUU = d55.Caption
    MBUU = IIf(DBUU < 15, 1, 0)
    CommandButton1_Click
End Sub

Private Sub d56_Click()
Unload rili
UserForm1.TextBox1.Value = Format(Date, "yyyy/dd/mm")
    DBUU = d56.Caption
    MBUU = IIf(DBUU < 15, 1, 0)
    CommandButton1_Click
End Sub

Private Sub d57_Click()
Unload rili
UserForm1.TextBox1.Value = Format(Date, "yyyy/dd/mm")
    DBUU = d57.Caption
    MBUU = IIf(DBUU < 15, 1, 0)
    CommandButton1_Click
End Sub
Private Sub d61_Click()
Unload rili
UserForm1.TextBox1.Value = Format(Date, "yyyy/dd/mm")
    DBUU = d61.Caption
    MBUU = IIf(DBUU < 15, 1, 0)
    CommandButton1_Click
End Sub

Private Sub d62_Click()
Unload rili
UserForm1.TextBox1.Value = Format(Date, "yyyy/dd/mm")
    DBUU = d62.Caption
    MBUU = IIf(DBUU < 15, 1, 0)
    CommandButton1_Click
End Sub

Private Sub d63_Click()
Unload rili
UserForm1.TextBox1.Value = Format(Date, "yyyy/dd/mm")
    DBUU = d63.Caption
    MBUU = IIf(DBUU < 15, 1, 0)
    CommandButton1_Click
End Sub

Private Sub d64_Click()
Unload rili
UserForm1.TextBox1.Value = Format(Date, "yyyy/dd/mm")
    DBUU = d64.Caption
    MBUU = IIf(DBUU < 15, 1, 0)
    CommandButton1_Click
End Sub

Private Sub d65_Click()
Unload rili
UserForm1.TextBox1.Value = Format(Date, "yyyy/dd/mm")
    DBUU = d65.Caption
    MBUU = IIf(DBUU < 15, 1, 0)
    CommandButton1_Click
End Sub

Private Sub d66_Click()
Unload rili
UserForm1.TextBox1.Value = Format(Date, "yyyy/dd/mm")
    DBUU = d66.Caption
    MBUU = IIf(DBUU < 15, 1, 0)
    CommandButton1_Click
End Sub

Private Sub d67_Click()
Unload rili
UserForm1.TextBox1.Value = Format(Date, "yyyy/dd/mm")
    DBUU = d67.Caption
    MBUU = IIf(DBUU < 15, 1, 0)
    CommandButton1_Click
End Sub
Private Sub UserForm_Activate()
    ComboBox1.Value = Year(Now())
    ComboBox2.Value = Month(Now())
    UserForm_Initialize
End Sub
Private Sub UserForm_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
Unload rili
UserForm1.TextBox1.Value = Format(Date, "yyyy/dd/mm")
    ComboBox1.Value = Year(Now())
    ComboBox2.Value = Month(Now())
    UserForm_Initialize
End Sub

Private Sub CommandButton2_Click()
Unload rili
UserForm1.TextBox1.Value = Format(Date, "yyyy/dd/mm")
    ComboBox1.Value = Year(Now())
    ComboBox2.Value = Month(Now())
    UserForm_Initialize
End Sub

TA的精华主题

TA的得分主题

 楼主| 发表于 2019-11-13 11:28 | 显示全部楼层
wj2368 发表于 2019-11-13 10:05
用自己注册的日历插件,MSCOMCT2.OCX(网上有下载)

谢谢,但是公司电脑有限制了,弄不了,不然我也不会这么折腾了,为了这个熬了好几个夜晚,掉了好多头发

TA的精华主题

TA的得分主题

发表于 2019-11-13 13:57 来自手机 | 显示全部楼层
本帖最后由 lss001 于 2019-11-13 16:11 编辑

~\(≧▽≦)/~~\(≧▽≦)/~

TA的精华主题

TA的得分主题

 楼主| 发表于 2019-11-13 15:11 | 显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件       ★免费下载 ★       ★ 使用帮助
lss001 发表于 2019-11-13 13:57
交换一下位置即可,举例如下→
Private Sub CommandButton2_Click()
    ComboBox1.Value = Year(Now())
...

还是有问题,这样改了之后,把值给到单元格内了,没有给到textbox1内,而且是年/月/日 时:分的格式。
看来这段代码没起作用--> userform1.textbox1.value=format(date,"yyyy/dd/mm"

TA的精华主题

TA的得分主题

发表于 2019-11-13 16:20 来自手机 | 显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件       ★免费下载 ★       ★ 使用帮助
本帖最后由 lss001 于 2019-11-13 21:35 编辑


TA的精华主题

TA的得分主题

 楼主| 发表于 2019-11-13 19:55 | 显示全部楼层
lss001 发表于 2019-11-13 16:20
楼上只是举例,其中Date要根据实际单击事件填写(比如您单击的是1号,那么Date就应改为xxxxxx01,其中xxxxx ...

我要崩溃了
能不能帮我写出来啊,太难弄了

TA的精华主题

TA的得分主题

发表于 2019-11-14 08:59 | 显示全部楼层
aideng0507 发表于 2019-11-13 11:28
谢谢,但是公司电脑有限制了,弄不了,不然我也不会这么折腾了,为了这个熬了好几个夜晚,掉了好多头发 : ...

重新给你做了一个
1.gif

test.rar

32.1 KB, 下载次数: 179

评分

1

查看全部评分

TA的精华主题

TA的得分主题

 楼主| 发表于 2019-11-14 18:41 | 显示全部楼层
wj2368 发表于 2019-11-14 08:59
重新给你做了一个

非常非常感谢,这个满足了我的所有要求。
真的是太厉害了,人也特别好,谢谢。
您需要登录后才可以回帖 登录 | 免费注册

本版积分规则

手机版|关于我们|联系我们|ExcelHome

GMT+8, 2024-11-18 13:54 , Processed in 0.036088 second(s), 10 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 1999-2023 Wooffice Inc.

沪公网安备 31011702000001号 沪ICP备11019229号-2

本论坛言论纯属发表者个人意见,任何违反国家相关法律的言论,本站将协助国家相关部门追究发言者责任!     本站特聘法律顾问:李志群律师

快速回复 返回顶部 返回列表