Excel使用日历控件
2015-07-28 17:20
363 查看
在导入日历控件后,可以通过如下代码,在Excel的表格中获得对应选择日期的值.
来自:http://blog.csdn.net/lan120576664
Private Sub DTPicker1_Change() Dim sDate As String, sTime As String sDate = Format$(DTPicker1.Value, "MM/dd") sTime = Format$(DTPicker1.Value, "HH:mm") ActiveCell.Value = sDate + vbCrLf + sTime If DTPicker1.Visible = 1 Then DTPicker1.Visible = False End If End Sub Private Sub DTPicker1_KeyDown(KeyCode As Integer, ByVal Shift As Integer) If KeyCode = 13 Then Dim sDate As String, sTime As String sDate = Format$(DTPicker1.Value, "MM/dd") sTime = Format$(DTPicker1.Value, "HH:mm") ActiveCell.Value = sDate + vbCrLf + sTime If DTPicker1.Visible = 1 Then DTPicker1.Visible = False End If End If End Sub Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim sDate As String, sTime As String With Me.DTPicker1 If Target.Column = 2 And Target.Count = 1 And Target.Row > 8 Then .Visible = True .Width = Target.Width + 15 .Left = Target.Left .Top = Target.Top .Height = Target.Height .Value = Now Else .Visible = False End If End With End Sub
来自:http://blog.csdn.net/lan120576664
相关文章推荐
- 找出BST上任意节点的下一个节点
- Objective-C property详解
- 利用openSSL 生成RSA公钥和密钥
- jquery.uploadify-3.1+servlet实现多文件的上传和下载文件存储到BLOB中
- CSS 多浏览器兼容性问题及解决方案
- u-boot 编译,调试及技巧
- /=============分隔线=============/
- 数组中插入1-100数字,数字不能重复.
- Android 颜色渲染 PorterDuff及Xfermode详解
- 函数封装(数组的使用,通过棋盘游戏)
- CSS中的一些百分比相关调试经验分享
- HTML 表格(1)
- MySQL调优
- box草稿1
- 当html页面乱码需要修改编码时
- Android获取验证码后倒计时程序
- nginx集群客户端分配策略
- 详细说明C++笔试题,调查超载、盖、多态
- self-introduction
- 计算机网络(二)