刚刚开始研究vba,研究了《excel实战精粹》这本书中关于vba日历控件安装的实例。发现有些问题。请版主帮忙看看。 问题:1。在每次点击日历后,日历不消失。 2.点击的日历时间不在本单元格实现,而在下次点击的单元格中实现。 'sheet1中的代码 Private Sub calendar1_CloseUp() Application.EnableEvents = False ActiveCell.Value = Calendar1.Value Calendar1.Visible = False Application.EnableEvents = True End Sub Private Sub Worksheet_Change(ByVal Target As Range) If Target.Count = 1 Then If Target.Column = 3 And Target = "" Then Calendar1.Visible = False End If End If End Sub Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.Count = 1 Then If Target.Column = 3 Then With Calendar1 If Target <> "" Then .Value = Target End If .Visible = True .Top = Target.Top .Left = Target.Left Application.EnableEvents = False ActiveCell.Value = Calendar1.Value Application.EnableEvents = True End With Else Calendar1.Visible = False End If End If End Sub =============== 'thisworkbook中的代码 Private Sub workbook_open() With Sheet1.Calendar1 .Height = Sheet1.Cells(1, 3).Height + 100 .Width = Sheet1.Cells(1, 3).Width + 70 .Visible = False End With End Sub
d6pwdZGD.rar
(12.14 KB, 下载次数: 314)
[此贴子已经被gouweicao78于2007-7-12 18:28:28编辑过] |