View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
tracktor tracktor is offline
external usenet poster
 
Posts: 17
Default Adding Calendar to Worksheet

This did not work. I get a compile error. Invalid or unqualified reference.
Here is the code that I put in the VB Editor:

Private Sub MonthView1_DateClick(ByVal DateClicked As Date)
Range("H2").Value = MonthView1.Value
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
MonthView1 .Visible = Target.Address = "$H$2"
End Sub

This line is highlited yellow:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)


"Rick Rothstein (MVP - VB)" wrote:

If you do not already have the Visual Basic toolbar displayed, click
View/Toolbars from Excel's menu bar and select it from the list of Toolbars
available. Next, click its Control Toolbox icon (looks like a wrench and
hammer crossing each other). Next, click the More Controls icon on the
Control Toolbox (also looks like a wrench and hammer crossing each other)
and select Microsoft Month View Control from the list, then click on the
worksheet to place it. Move it near the cell you want it to become visible
for when selected. Right click the MonthView Control and select Properties
from the popup list that appears. Set the Visible property to False. Also,
you can control the size of the MonthView Control by changing its Font Size
(click Font, then the ellipsis button). You can now dismiss the Properties
window and double click the MonthView Control to get into the VBA editor.
Copy/Paste this code in the code window that appeared...

Private Sub MonthView1_DateClick(ByVal DateClicked As Date)
Range("H5").Value = MonthView1.Value
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
MonthView1 .Visible = Target.Address = "$H$5"
End Sub

Note: Change the "H5" and "$H$5" example values to the cell address you want
the functionality for (the addresses must be the same and the one in the
SelectionChange event *must* be an absolute address. Go back to the
worksheet and turn off Design Mode and dismiss the Control Toolbox (click
their icons on the Visual Basic toolbar). That's it... it should work
automatically from here on out.

Rick


"tracktor" wrote in message
...
I want to add a calender to my worksheet that when a user selects a
specific
cell the calender will come up, the user can select a date, and it will
fill
the cell with that date, then when the user goes to the next cell the
calender dissapears, but the date stays in the specific cell.