ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   calendar control in 3 columns (https://www.excelbanter.com/excel-discussion-misc-queries/135437-calendar-control-3-columns.html)

tmirelle

calendar control in 3 columns
 
If I change the range to include 2 columns it still works

If Not Application.Intersect(Range("A2:A200", "F2:F200"), Target) Is Nothing
Then


But if I add a third it doesn't work... is there a way to make it?

If Not Application.Intersect(Range("A2:A200", "F2:F200", "G2:G200"), Target)
Is Nothing Then


here is the starting code:

Private Sub Calendar1_Click()
ActiveCell.Value = CDbl(Calendar1.Value)
' ActiveCell.NumberFormat = "dd/mmm/yy"
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("A2:A200"), 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
If IsDate(ActiveCell.Value) Then
Calendar1.Value = DateValue(ActiveCell.Value)
Else
Calendar1.Value = Date
End If
End Sub


Ron de Bruin

calendar control in 3 columns
 
Hi tmirelle

See the example on my site

Note: you can use this if your range is not one area
If Not Application.Intersect(Range("A1:A20,C1,E1"), Target) Is Nothing Then



--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"tmirelle" wrote in message ...
If I change the range to include 2 columns it still works

If Not Application.Intersect(Range("A2:A200", "F2:F200"), Target) Is Nothing
Then


But if I add a third it doesn't work... is there a way to make it?

If Not Application.Intersect(Range("A2:A200", "F2:F200", "G2:G200"), Target)
Is Nothing Then


here is the starting code:

Private Sub Calendar1_Click()
ActiveCell.Value = CDbl(Calendar1.Value)
' ActiveCell.NumberFormat = "dd/mmm/yy"
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("A2:A200"), 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
If IsDate(ActiveCell.Value) Then
Calendar1.Value = DateValue(ActiveCell.Value)
Else
Calendar1.Value = Date
End If
End Sub


tmirelle

calendar control in 3 columns
 
Thanks!

"Ron de Bruin" wrote:

Hi tmirelle

See the example on my site

Note: you can use this if your range is not one area
If Not Application.Intersect(Range("A1:A20,C1,E1"), Target) Is Nothing Then



--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"tmirelle" wrote in message ...
If I change the range to include 2 columns it still works

If Not Application.Intersect(Range("A2:A200", "F2:F200"), Target) Is Nothing
Then


But if I add a third it doesn't work... is there a way to make it?

If Not Application.Intersect(Range("A2:A200", "F2:F200", "G2:G200"), Target)
Is Nothing Then


here is the starting code:

Private Sub Calendar1_Click()
ActiveCell.Value = CDbl(Calendar1.Value)
' ActiveCell.NumberFormat = "dd/mmm/yy"
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("A2:A200"), 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
If IsDate(ActiveCell.Value) Then
Calendar1.Value = DateValue(ActiveCell.Value)
Else
Calendar1.Value = Date
End If
End Sub




All times are GMT +1. The time now is 04:31 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com