ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   have a date cell pop up a monthly calendar to choose a date (https://www.excelbanter.com/excel-worksheet-functions/41462-have-date-cell-pop-up-monthly-calendar-choose-date.html)

lillywhite

have a date cell pop up a monthly calendar to choose a date
 
Can I create a date cell that will pop up a monthly calendar from which I can
choose a date, and which will allow me to scroll forward or back through the
months of the year and even into future years.

venspen



"lillywhite" wrote:

Can I create a date cell that will pop up a monthly calendar from which I can
choose a date, and which will allow me to scroll forward or back through the
months of the year and even into future years.


Put a monthview control on your worksheet near the cell you want to enter
the date into. Set it's visible property to false.

In this case when the user enters cell A6 the monthview will become visible.
When the user double clicks on the date they want A6 will now have that date
and the monthview will hide itself.

In the sheets code window paste the following code:

Private Sub MonthView1_DblClick()
With MonthView1
ActiveCell.Value = .Value
.Visible = False
End With
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
Dim rng As Range
Set rng = Application.Intersect(Target, Range("B6"))
With MonthView1
If Not rng Is Nothing Then
.Visible = True
.Top = Target.Top
.Left = Target.Left
Else
.Visible = False
End If
End With
End Sub

Rob

Hi,

I'd also like to do what lillywhite asked but can't figure out where the
monthview object comes from - can you perhaps give me some pointers.
Thanks, Rob
"venspen" wrote in message
...


"lillywhite" wrote:

Can I create a date cell that will pop up a monthly calendar from which I
can
choose a date, and which will allow me to scroll forward or back through
the
months of the year and even into future years.


Put a monthview control on your worksheet near the cell you want to enter
the date into. Set it's visible property to false.

In this case when the user enters cell A6 the monthview will become
visible.
When the user double clicks on the date they want A6 will now have that
date
and the monthview will hide itself.

In the sheets code window paste the following code:

Private Sub MonthView1_DblClick()
With MonthView1
ActiveCell.Value = .Value
.Visible = False
End With
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
Dim rng As Range
Set rng = Application.Intersect(Target, Range("B6"))
With MonthView1
If Not rng Is Nothing Then
.Visible = True
.Top = Target.Top
.Left = Target.Left
Else
.Visible = False
End If
End With
End Sub




venspen



"Rob" wrote:

Hi,

I'd also like to do what lillywhite asked but can't figure out where the
monthview object comes from - can you perhaps give me some pointers.
Thanks, Rob
"venspen" wrote in message
...


"lillywhite" wrote:

Can I create a date cell that will pop up a monthly calendar from which I
can
choose a date, and which will allow me to scroll forward or back through
the
months of the year and even into future years.


Put a monthview control on your worksheet near the cell you want to enter
the date into. Set it's visible property to false.

In this case when the user enters cell A6 the monthview will become
visible.
When the user double clicks on the date they want A6 will now have that
date
and the monthview will hide itself.

In the sheets code window paste the following code:

Private Sub MonthView1_DblClick()
With MonthView1
ActiveCell.Value = .Value
.Visible = False
End With
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
Dim rng As Range
Set rng = Application.Intersect(Target, Range("B6"))
With MonthView1
If Not rng Is Nothing Then
.Visible = True
.Top = Target.Top
.Left = Target.Left
Else
.Visible = False
End If
End With
End Sub





Sorry about that, my bad! I think that Monthview is a control that is
installed with Visual Basic 6. You can use the Calendar Control in the same
fashion:

Private Sub Calendar1_DblClick()
With Calendar1
ActiveCell.Value = .Value
.Visible = False
End With
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
Dim rng As Range
Set rng = Application.Intersect(Target, Range("B6"))
With Calendar1
If Not rng Is Nothing Then
.Visible = True
.Top = Target.Top
.Left = Target.Left
Else
.Visible = False
End If
End With
End Sub

Rob

Thanks, Calendar Control has done it. Appreciate your help.

Rob
"venspen" wrote in message
...


"Rob" wrote:

Hi,

I'd also like to do what lillywhite asked but can't figure out where the
monthview object comes from - can you perhaps give me some pointers.
Thanks, Rob
"venspen" wrote in message
...


"lillywhite" wrote:

Can I create a date cell that will pop up a monthly calendar from
which I
can
choose a date, and which will allow me to scroll forward or back
through
the
months of the year and even into future years.

Put a monthview control on your worksheet near the cell you want to
enter
the date into. Set it's visible property to false.

In this case when the user enters cell A6 the monthview will become
visible.
When the user double clicks on the date they want A6 will now have that
date
and the monthview will hide itself.

In the sheets code window paste the following code:

Private Sub MonthView1_DblClick()
With MonthView1
ActiveCell.Value = .Value
.Visible = False
End With
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
Dim rng As Range
Set rng = Application.Intersect(Target, Range("B6"))
With MonthView1
If Not rng Is Nothing Then
.Visible = True
.Top = Target.Top
.Left = Target.Left
Else
.Visible = False
End If
End With
End Sub





Sorry about that, my bad! I think that Monthview is a control that is
installed with Visual Basic 6. You can use the Calendar Control in the
same
fashion:

Private Sub Calendar1_DblClick()
With Calendar1
ActiveCell.Value = .Value
.Visible = False
End With
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
Dim rng As Range
Set rng = Application.Intersect(Target, Range("B6"))
With Calendar1
If Not rng Is Nothing Then
.Visible = True
.Top = Target.Top
.Left = Target.Left
Else
.Visible = False
End If
End With
End Sub





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

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