Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456 カレンダーコントロール:Excel VBA入門
連続入力にするにはモードレスに設定します。
Sub myCalendar()
UserForm1.Show vbModeless
End Sub
UserForm1でコードを表示し、以下のコードを入力します。
Calendar1をクリックしたら、アクティブセルがA列のセルであるかどうかを判定し、A列のセルであったら日付を入力します。
Private Sub Calendar1_Click()
If Intersect(ActiveCell, Range("A:A")) Is Nothing Then Exit
Sub
ActiveCell.Value = Calendar1.Value
End Sub
Calendar1の初期値を今日の日付にします。
Private Sub UserForm_Initialize()
Calendar1.Value = Date
End Sub
UserForm1を閉じたらUserForm1を削除します。
Private Sub UserForm_Deactivate()
Unload UserForm1
End Sub