Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 586
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default 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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
is there a formula that will subtract todays date from a hire date Heather Excel Worksheet Functions 5 April 25th 23 07:44 PM
graphing data based on todays date Soccerboy83 Excel Discussion (Misc queries) 3 June 9th 09 04:57 AM
Create a button that will date stamp todays date in a cell Tom Meacham Excel Discussion (Misc queries) 3 January 11th 06 01:08 AM
When I open my past invoice it keeps changing date to todays date Stop date changing to todays in Excel Excel Worksheet Functions 2 October 7th 05 04:54 PM
Use button on sheet to transfer data based on todays date Qaspec Excel Programming 0 January 25th 05 02:01 AM


All times are GMT +1. The time now is 10:52 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"