Calendar default date

C

clayton

Using excels calendar on a worksheet works great. However I would lik
it to default to todays date. I would think this would be the defaul
but I guess not.

I have inserted an Calendar 8.0 object.
I have inserted the following code in the worksheets code.

Private Sub Calendar1_Click()
'ActiveCell.NumberFormat = "m/d/yyyy"
ActiveCell = Calendar1.Value
Calendar1.Visible = False
Range("e27").Select
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Target.Column = 2 And Target.Row = 27 Then
Range("c27").activate
ActiveCell.Font.Size = 12
ActiveCell.Font.Bold = True
ElseIf Target.Column = 3 And Target.Row = 27 Then
Range("c27").activate
ActiveCell.Font.Size = 12
ActiveCell.Font.Bold = True
ElseIf Target.Column = 4 And Target.Row = 27 Then
Range("c27").activate
ActiveCell.Font.Size = 12
ActiveCell.Font.Bold = True
End If

If Not Application.Intersect(Range("b27:d27"), Target) Is Nothin
Then
Calendar1.Left = Target.Left + Target.Width - Calendar1.Width
Calendar1.Top = Target.Top + Target.Height
Calendar1.Visible = True


Else: Calendar1.Visible = False
End If
End Sub


It works great but just does not default to the current date...

Thanks for any help
 
G

Guest

Try this

Private Sub UserForm_Initialize(
If IsDate(Selection.Value) The
Calendar1.Value = DateValue(Selection.Value
Els
Calendar1.Value = Int(date
Selection.NumberFormat = "mm/dd/yy
End I
End Sub
 
C

clayton

This is in a worksheet that I am trying to make this work with. It look
like this is for a userform?
I tried a few different thing with the code you wrote but couldnt ge
it to work. Also, I was assuming I should just put that in with th
code I posted in the first post correct
 

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