Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Date picker control
I have added two date picker controls to a worksheet.
On one control: I would like to default to today's date whenever the workbook is opened. On the other control: I would like to default the date to today + 2 weeks. How do i set a default value for these controls? -- Thanks in advance |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Date picker control
Open VBA Editor ans select This Workbook in the project browser
Something similar to this in a workbook open event. Private Sub Workbook_Open() 'Must be this sub name Dim TodaysDate As Date Dim TodayFortnightDate As Date Sheets("ExcelControls").Select 'Use your sheet name TodaysDate = Date TodayFortnightDate = Date + 14 Sheets("ExcelControls").CommandButton1.Caption = Format _ (TodaysDate, "dd/mm/yyyy") Sheets("ExcelControls").CommandButton2.Caption = Format _ (TodayFortnightDate , "dd/mm/yyyy") End Sub "GeraldM" wrote: I have added two date picker controls to a worksheet. On one control: I would like to default to today's date whenever the workbook is opened. On the other control: I would like to default the date to today + 2 weeks. How do i set a default value for these controls? -- Thanks in advance |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Date picker control
I have had another read of your request and now I am not sure whether it is
the default value to process that you want to change or the caption. If it is the value then basically the same but substitue caption with value and you may be able to leave the format function out. However, you cannot set a value for a control button and I don't know what sort of control you have so my example is for a ComboBox eg. Sheets("ExcelControls").ComboBox1.Value = TodaysDate "OssieMac" wrote: Open VBA Editor ans select This Workbook in the project browser Something similar to this in a workbook open event. Private Sub Workbook_Open() 'Must be this sub name Dim TodaysDate As Date Dim TodayFortnightDate As Date Sheets("ExcelControls").Select 'Use your sheet name TodaysDate = Date TodayFortnightDate = Date + 14 Sheets("ExcelControls").CommandButton1.Caption = Format _ (TodaysDate, "dd/mm/yyyy") Sheets("ExcelControls").CommandButton2.Caption = Format _ (TodayFortnightDate , "dd/mm/yyyy") End Sub "GeraldM" wrote: I have added two date picker controls to a worksheet. On one control: I would like to default to today's date whenever the workbook is opened. On the other control: I would like to default the date to today + 2 weeks. How do i set a default value for these controls? -- Thanks in advance |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Date picker control | Excel Discussion (Misc queries) | |||
Custom Date Picker Control | Excel Programming | |||
Custom Date Picker Control | Excel Programming | |||
date time picker control | Excel Programming | |||
Date and Time Picker Control | Excel Discussion (Misc queries) |