#1   Report Post  
Posted to microsoft.public.excel.misc
Shane
 
Posts: n/a
Default Calendar control

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




  #2   Report Post  
Posted to microsoft.public.excel.misc
Ian
 
Posts: n/a
Default Calendar control

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


--
Ian
--
"Shane" wrote in message
...
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






  #3   Report Post  
Posted to microsoft.public.excel.misc
Shane
 
Posts: n/a
Default Calendar control

Thank you very much

Shane

"Ian" wrote:

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


--
Ian
--
"Shane" wrote in message
...
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







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
How to insert date using a pop up calendar control in a cell i Iain the scout Excel Discussion (Misc queries) 4 December 17th 05 08:10 PM
calendar control 10.0 timmulla Excel Discussion (Misc queries) 1 December 1st 05 12:38 AM
Calendar Control 11.0 MCorn Excel Discussion (Misc queries) 1 August 3rd 05 06:04 PM
calendar control - formatting arnoldarmy Excel Discussion (Misc queries) 1 April 25th 05 04:36 PM
how do you use the ActiveX Calendar control in an Excel Worksheet. EricF Excel Worksheet Functions 0 November 10th 04 09:39 PM


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

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

About Us

"It's about Microsoft Excel"