copy value calendar control

R

Rhino V

This is a 2 part question:
I have a calendar control attached to 3 cells (C6, E6, E7) designating
travel dates on the same sheet so users can pick the desired date they wish
to input.

Question 1: Once the date is chosen (which is always in the future from
today) why does it still show today's date when the cell is re-selected even
though another date has already been chosen? Can it be set to default to the
cell's already entered value?

Question 2: Once a date is selected for C6, how can E6 be defaulted to the
value of C6 so that date can be used as the starting point for the next
input? Do several Calendar Controls need to be set up for this to work?

Thank you in advance for any and all help on this.
 
G

Gord Dibben

Point 1...............

Can't see your calendar click code but this is what I have behind my
calendar control I got from Martin Green's site.

The Initializing being the important bit which sets calendar default to cell
date if one is currently in that cell.

Option Explicit

' ===================================================
' Code by Martin Green eMail (e-mail address removed)
' Visit my Office Tips web site at www.fontstuff.com
' ===================================================

Private Sub cmdClose_Click()
' Close the UserForm
Unload Me
End Sub

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") ''Date
End If
End Sub

Private Sub Calendar1_Click()
' Transfer date selected on calendar to active cell
' and close UserForm.
ActiveCell.Value = Format(Calendar1.Value, "dd-mmm-yy")
Unload Me
End Sub

Point 2...................

In E6 enter =C6


Gord Dibben MS Excel MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top