close

Hi, I'm using the calendar function so when you click on a calendar icon it
brings up the calendar and when you select the correct date it inserts it
into the relevant cell I want. My trouble is that when you load the calendar
the date it opens at is not quot;Todaysquot; date. I would like the calendar when
clicked to open to be on todays date - how do I do this?

I'm making an assumption that you're using the date picker ActiveX control.
If so, you can place the following code in your workbooks module for the
OnOpen event. Modify the Date Picker name to refernce whatever name you've
assigned to it. If your unsure, open the Control Toolbox tool bar, click the
Design button and the right click on your calendar control and select
properties.

Private Sub Workbook_Open()

Dim dtPicker As dtPicker

Set dtPicker = ActiveWorkbook.Sheets(quot;Sheet1quot;).DTPicker1

dtPicker.Month = Month(Date)
dtPicker.Day = Day(Date)
dtPicker.Year = Year(Date)End Sub

--
Kevin Backmannquot;Dawnquot; wrote:

gt; Hi, I'm using the calendar function so when you click on a calendar icon it
gt; brings up the calendar and when you select the correct date it inserts it
gt; into the relevant cell I want. My trouble is that when you load the calendar
gt; the date it opens at is not quot;Todaysquot; date. I would like the calendar when
gt; clicked to open to be on todays date - how do I do this?

Thanks Kevin, I'll give it a go - DAWN

quot;Kevin Bquot; wrote:

gt; I'm making an assumption that you're using the date picker ActiveX control.
gt; If so, you can place the following code in your workbooks module for the
gt; OnOpen event. Modify the Date Picker name to refernce whatever name you've
gt; assigned to it. If your unsure, open the Control Toolbox tool bar, click the
gt; Design button and the right click on your calendar control and select
gt; properties.
gt;
gt; Private Sub Workbook_Open()
gt;
gt; Dim dtPicker As dtPicker
gt;
gt; Set dtPicker = ActiveWorkbook.Sheets(quot;Sheet1quot;).DTPicker1
gt;
gt; dtPicker.Month = Month(Date)
gt; dtPicker.Day = Day(Date)
gt; dtPicker.Year = Year(Date)
gt;
gt;
gt; End Sub
gt;
gt; --
gt; Kevin Backmann
gt;
gt;
gt; quot;Dawnquot; wrote:
gt;
gt; gt; Hi, I'm using the calendar function so when you click on a calendar icon it
gt; gt; brings up the calendar and when you select the correct date it inserts it
gt; gt; into the relevant cell I want. My trouble is that when you load the calendar
gt; gt; the date it opens at is not quot;Todaysquot; date. I would like the calendar when
gt; gt; clicked to open to be on todays date - how do I do this?

Kevin,

I've tried it, but to be honest I dont know what I am doing.

My calendar which I have an icon on the spreadsheet when pressed it runs a
macro called quot;show itquot;

Sub ShowIt()

UserForm2.Show
End Sub

This then brings up a calendar and when I click on the date I want the code
attached to the Form does the below.

End SubPrivate Sub Calendar1_Click()
Range(quot;B7quot;) = Calendar1.Value

End Sub

Private Sub UserForm2_Activate()
Me.Calendar1.Value = Date
End Sub

Private Sub UserForm_Click()

End SubThis then puts the date I have chosen in my spreadsheet. Where do I put the
code you have given below.

Thanks DAWN
quot;Kevin Bquot; wrote:

gt; I'm making an assumption that you're using the date picker ActiveX control.
gt; If so, you can place the following code in your workbooks module for the
gt; OnOpen event. Modify the Date Picker name to refernce whatever name you've
gt; assigned to it. If your unsure, open the Control Toolbox tool bar, click the
gt; Design button and the right click on your calendar control and select
gt; properties.
gt;
gt; Private Sub Workbook_Open()
gt;
gt; Dim dtPicker As dtPicker
gt;
gt; Set dtPicker = ActiveWorkbook.Sheets(quot;Sheet1quot;).DTPicker1
gt;
gt; dtPicker.Month = Month(Date)
gt; dtPicker.Day = Day(Date)
gt; dtPicker.Year = Year(Date)
gt;
gt;
gt; End Sub
gt;
gt; --
gt; Kevin Backmann
gt;
gt;
gt; quot;Dawnquot; wrote:
gt;
gt; gt; Hi, I'm using the calendar function so when you click on a calendar icon it
gt; gt; brings up the calendar and when you select the correct date it inserts it
gt; gt; into the relevant cell I want. My trouble is that when you load the calendar
gt; gt; the date it opens at is not quot;Todaysquot; date. I would like the calendar when
gt; gt; clicked to open to be on todays date - how do I do this?

Now that I've had some sleep, it was around 1:00 AM when I read your
question, it seems to me that you have standard calendar control on your form.

If you put this in your form's module, for the Initialize event, it well set
the standard calendar control to the current date.

You can use DateSerial(Year, Month, Day) to set it any date you wish, with
the year, month and day being entered as integers.

Hope this helps, if not post again
Private Sub UserForm_Initialize()

Me.Calendar1.Value = DateEnd Sub

--
Kevin Backmannquot;Dawnquot; wrote:

gt; Kevin,
gt;
gt; I've tried it, but to be honest I dont know what I am doing.
gt;
gt; My calendar which I have an icon on the spreadsheet when pressed it runs a
gt; macro called quot;show itquot;
gt;
gt; Sub ShowIt()
gt;
gt; UserForm2.Show
gt; End Sub
gt;
gt; This then brings up a calendar and when I click on the date I want the code
gt; attached to the Form does the below.
gt;
gt; End Sub
gt;
gt;
gt; Private Sub Calendar1_Click()
gt; Range(quot;B7quot;) = Calendar1.Value
gt;
gt; End Sub
gt;
gt; Private Sub UserForm2_Activate()
gt; Me.Calendar1.Value = Date
gt; End Sub
gt;
gt; Private Sub UserForm_Click()
gt;
gt; End Sub
gt;
gt;
gt; This then puts the date I have chosen in my spreadsheet. Where do I put the
gt; code you have given below.
gt;
gt; Thanks DAWN
gt; quot;Kevin Bquot; wrote:
gt;
gt; gt; I'm making an assumption that you're using the date picker ActiveX control.
gt; gt; If so, you can place the following code in your workbooks module for the
gt; gt; OnOpen event. Modify the Date Picker name to refernce whatever name you've
gt; gt; assigned to it. If your unsure, open the Control Toolbox tool bar, click the
gt; gt; Design button and the right click on your calendar control and select
gt; gt; properties.
gt; gt;
gt; gt; Private Sub Workbook_Open()
gt; gt;
gt; gt; Dim dtPicker As dtPicker
gt; gt;
gt; gt; Set dtPicker = ActiveWorkbook.Sheets(quot;Sheet1quot;).DTPicker1
gt; gt;
gt; gt; dtPicker.Month = Month(Date)
gt; gt; dtPicker.Day = Day(Date)
gt; gt; dtPicker.Year = Year(Date)
gt; gt;
gt; gt;
gt; gt; End Sub
gt; gt;
gt; gt; --
gt; gt; Kevin Backmann
gt; gt;
gt; gt;
gt; gt; quot;Dawnquot; wrote:
gt; gt;
gt; gt; gt; Hi, I'm using the calendar function so when you click on a calendar icon it
gt; gt; gt; brings up the calendar and when you select the correct date it inserts it
gt; gt; gt; into the relevant cell I want. My trouble is that when you load the calendar
gt; gt; gt; the date it opens at is not quot;Todaysquot; date. I would like the calendar when
gt; gt; gt; clicked to open to be on todays date - how do I do this?

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 software 的頭像
    software

    software

    software 發表在 痞客邦 留言(0) 人氣()