Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Load Calendar in VBA

Status
Not open for further replies.

smartrider

Programmer
Apr 18, 2003
21
0
0
US
I have question about Calendar

I want to load a calendar with current month.

I have

sub calender_click()
Calendar.show
end sub

Please help
 
in the intialize part of the calendar you need to tell it to look at the current month all you need to do is add this line in and it will default to the current day.

calendar.value = date

calendar - should be the name of the calendar control, normally calendar1, or whatever you have called it.

Hope this helps.

Thanks Rob.[yoda]
 
Assuming you atre using VBA with Excel:

1. In the VBA interface (Alt+F11) Go to Tools / Additional controls and select Calendar Control - this adds the Calendar control to the toolbox

2. Create a new userform (insert /Userform) - in the properties window give the from a relevant name (e.g frmCal)

3. Click on the Calendar icon in the tool box and draw the calendar into frmCal. Resize as required. Call the calendar control an appropriatre name eg Cal1

4. Resize frmCal so that it is the same size as the calendar control

5. Create a new module (Insert / Module) and declare a public variable to hold the date returned by Cal1 - type "Public gdatCal as date"

6. Right click on the frmCal icon in project explorer and choose View code. In the left hand combo select UserForm and in the righthand combo select Terminate and type the following code in the form terminate procedure:

gDatCal = Me.Cal1.Value

This assigns the selected date to the gDatCal public variable

7. In the left hand combo select cal1 and in the right hand combo select double-click - in the procedure type "Unload me" This closes frmCal after the user double-clicks on it.

8. You would typically open the calendar by clicking on a command button on another user form or a worksheet - the code required to show the form is:

Load frmCal
frmCal.Show



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top