Miguelluis
New Member
- Joined
- Jan 29, 2013
- Messages
- 45
Hi
I'm trying to add a date picker to a sheet that will run when a user selects a cell in column A. I got as far as being able to run it any where on my workbook but I am having problems containing it to column A nor can I figure out how to make the date picker appear when I select a cell in column A.
With a youtube videao I created a form and a module and the code for this is below, Is any one able to help me run this when a user selects a cell in column A?
Form code:
Private Sub cmdClose_Click()
Unload Me
End Sub
Private Sub MonthView1_DateClick(ByVal DateClicked As Date)
On Error Resume Next
Dim cell As Object
For Each cell In Selection.Cells
cell.Value = Me.MonthView1.Value
Next cell
Unload Me
End Sub
Private Sub UserForm_Initialize()
If IsDate(ActiveCell.Value) Then
Me.MonthView1.Value = ActiveCell.Value
End If
End Sub
------------------------------------------------------------------------------
Workbook code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
On Error Resume Next
Application.OnKey "+^{C}"
Application.CommandBars("cell").Controls("Insert Date").Delete
End Sub
Private Sub Workbook_Open()
On Error Resume Next
Dim newcontrol As CommandBarControl
Application.OnKey "+^{C}", "Module1.OpenCalendar"
Application.CommandBars("cell").Controls("Insert Date").Delete
Set newcontrol = Application.CommandBars("Cell").Controls.Add
With newcontrol
.Caption = "Insert Date"
.OnAction = "Module1.OpenCalendar"
.BeginGroup = True
End With
End Sub
------------------------------------------------------------------
Module Code:
Sub OpenCalendar()
frmcalendar.Show
End Sub
Thank you
Miguel
I'm trying to add a date picker to a sheet that will run when a user selects a cell in column A. I got as far as being able to run it any where on my workbook but I am having problems containing it to column A nor can I figure out how to make the date picker appear when I select a cell in column A.
With a youtube videao I created a form and a module and the code for this is below, Is any one able to help me run this when a user selects a cell in column A?
Form code:
Private Sub cmdClose_Click()
Unload Me
End Sub
Private Sub MonthView1_DateClick(ByVal DateClicked As Date)
On Error Resume Next
Dim cell As Object
For Each cell In Selection.Cells
cell.Value = Me.MonthView1.Value
Next cell
Unload Me
End Sub
Private Sub UserForm_Initialize()
If IsDate(ActiveCell.Value) Then
Me.MonthView1.Value = ActiveCell.Value
End If
End Sub
------------------------------------------------------------------------------
Workbook code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
On Error Resume Next
Application.OnKey "+^{C}"
Application.CommandBars("cell").Controls("Insert Date").Delete
End Sub
Private Sub Workbook_Open()
On Error Resume Next
Dim newcontrol As CommandBarControl
Application.OnKey "+^{C}", "Module1.OpenCalendar"
Application.CommandBars("cell").Controls("Insert Date").Delete
Set newcontrol = Application.CommandBars("Cell").Controls.Add
With newcontrol
.Caption = "Insert Date"
.OnAction = "Module1.OpenCalendar"
.BeginGroup = True
End With
End Sub
------------------------------------------------------------------
Module Code:
Sub OpenCalendar()
frmcalendar.Show
End Sub
Thank you
Miguel