Set DTPickers Data to Todays Date by Default
I have a Userform with several DTPickers. Next to each DTPicker is a
checkbox. This is how I relate the checkbox and dtpicker, Checkbox1.Value = DTPicker1.Visible. How can I set the DTPickers date to todays date when the userform is intialized? Currently the date is the date I added it to the userform. This is what I use to get around it. Sub Userform_Initialize() ' set all dtp controls to todays date, ' if the DTPicker is not visible and you try to set the date you get an error For Each dtp In colDueDates With dtp If .Visible = False Then .Visible = True .Value = Date .Visible = False End If End With Next dtp End Sub -- Cheers, Ryan |
Set DTPickers Data to Todays Date by Default
Work this into your initialize
Private Sub UserForm_Initialize() ' Check if active cell contains a date. If 'yes' show ' same date on calendar. If 'no' show today's date. If IsDate(ActiveCell.Value) Then Calendar1.Value = DateValue(ActiveCell.Value) Else Calendar1.Value = Format(Date, "dd-mmm-yy") End If End Sub Gord Dibben MS Excel MVP On Mon, 20 Oct 2008 07:11:02 -0700, RyanH wrote: I have a Userform with several DTPickers. Next to each DTPicker is a checkbox. This is how I relate the checkbox and dtpicker, Checkbox1.Value = DTPicker1.Visible. How can I set the DTPickers date to todays date when the userform is intialized? Currently the date is the date I added it to the userform. This is what I use to get around it. Sub Userform_Initialize() ' set all dtp controls to todays date, ' if the DTPicker is not visible and you try to set the date you get an error For Each dtp In colDueDates With dtp If .Visible = False Then .Visible = True .Value = Date .Visible = False End If End With Next dtp End Sub |
All times are GMT +1. The time now is 01:58 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com