Calendar control

G

Guest

I have this code in an excel sheet, it brings up a calendar when I click a
cell in the range A1:A20, I can then click on a date and it populates the
cell selected with that date.



Problem is, I need this to apply to range C1:C20 and G1:G20, got any idea
how I can add the extra ranges in?



Thanks



Shane



Private Sub Calendar1_Click()

ActiveCell.Value = CDbl(Calendar1.Value)

ActiveCell.NumberFormat = "dd/mm/yyyy"

ActiveCell.Select

End Sub



Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Target.Cells.Count > 1 Then Exit Sub

If Not Application.Intersect(Range("A1:A50"), Target) Is Nothing Then

Calendar1.Left = Target.Left + Target.Width + Calendar1.Width

Calendar1.Top = Target.Top + Target.Height

Calendar1.Visible = True

' select Today's date in the Calendar

Calendar1.Value = Date

ElseIf Calendar1.Visible Then Calendar1.Visible = False

End If

End Sub
 
I

Ian

Your code selcts on A1 to A50, not A20 as you specified in the query.
This should select on A1:A20, C1:C20 and G1:G20
If Not Application.Intersect(Range("A1:A20,C1:C20,G1:G20"), Target) Is
Nothing Then
 
G

Guest

Thank you very much

Shane

Ian said:
Your code selcts on A1 to A50, not A20 as you specified in the query.
This should select on A1:A20, C1:C20 and G1:G20
If Not Application.Intersect(Range("A1:A20,C1:C20,G1:G20"), Target) Is
Nothing Then
 

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