还是关于日历控件的使用问题(VBA)2
发布网友
发布时间:2023-11-08 21:31
我来回答
共1个回答
热心网友
时间:2024-12-13 20:42
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If target.count=1 and (target.column=1 or target.column=13) then
Calendar1.Visible = True
select case target.column
case 1
Calendar1.Left = Target.Left + Target.Width '设置日历控件弹出的列位置
case 13
Calendar1.Left = Target.left-Calendar1.width '设置日历控件弹出的列位置
end select
Calendar1.Top = Target.Top + Target.Height '设置日历控件弹出的行位置
If Target.Value <> "" Then
Me.Calendar1.Value = Target.Value
Else
Me.Calendar1.Value = date
End If
Else
Me.Calendar1.Visible = False
End If
End Sub