非IT企業に勤める中年サラリーマンのIT日記

非IT企業でしかもITとは全く関係ない部署にいる中年エンジニア。唯一の趣味がプログラミングという”自称”プログラマー。

Calendar control for Excel VBA

      2016/06/11

[ad#top-1]
 

There is not a calendar control in Excel VBA, so I made it.
It can be downloaded from the following link.
https://sites.google.com/site/applistjp/calendarform-for-excelvba

The following figure is the calendar control I made. A left form is a sample to test it. When “Run” button is clicked, Calendar is shown. When a date box in Calendar is clicked, a date value is returned in TextBox

_a

As event processing of “Run” button, It’s only enough to write the following 3 lines code.

Private Sub CommandButton1_Click()
    Call CalendarForm.setDate(TextBox1.Text)
    Call CalendarForm.setCallBackControl(TextBox1)
    CalendarForm.Show
End Sub

Not only TextBox but also Label can be used.

Private Sub CommandButton1_Click()
    Call CalendarForm.setDate(Label1.Caption)
    Call CalendarForm.setCallBackControl(Label1)
    CalendarForm.Show
End Sub

As a characteristic function, date value can be put in Sheet Cell. The folloing is a example.
_b
The source code is following:

Sub sample_cell()
   Call CalendarForm.setDate(Range(“B2”))
   Call CalendarForm.setCallBackCell(“B2”)
   CalendarForm.Show
End Sub

 
[ad#ad-1]

スポンサーリンク

 - VBA