Notadumbblonde
Board Regular
- Joined
- Nov 18, 2003
- Messages
- 104
HELP!!! - I've been trying to hack some code I found on this forum.. Essentially I just want to create a menubar command that inserts the day of the week they select and add 2 weeks to the date to the column on the right of the date for today.
for example in al if they select august 1 from the calendar control, in b1 it would say august 14th.
I will add the original code I extracted in red below if it helps.
thanks
Private Sub Calendar1_Click()
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
ActiveCell.Value = CDbl(Calendar1.Value)
ActiveCell.NumberFormat = "mm/dd/yyyy"
ActiveCell.Select
ActiveCell.Offset(0, 1).Select
ActiveCell.NumberFormat = "mm/dd/yyyy"
ActiveCell.Offset(0, 1) = CDbl(Calendar1.Value + 14)
ActiveCell.Offset(0, 1).Select
ActiveCell.NumberFormat = "mm/dd/yyyy"
ActiveCell.Offset(1, 1).Select
End Sub
Private Sub Calendar1_Click()
ActiveCell.Value = CDbl(Calendar1.Value)
ActiveCell.NumberFormat = "mm/dd/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:A20"), 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
Else: Calendar1.Visible = False
End If
End Sub
for example in al if they select august 1 from the calendar control, in b1 it would say august 14th.
I will add the original code I extracted in red below if it helps.
thanks
Private Sub Calendar1_Click()
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
ActiveCell.Value = CDbl(Calendar1.Value)
ActiveCell.NumberFormat = "mm/dd/yyyy"
ActiveCell.Select
ActiveCell.Offset(0, 1).Select
ActiveCell.NumberFormat = "mm/dd/yyyy"
ActiveCell.Offset(0, 1) = CDbl(Calendar1.Value + 14)
ActiveCell.Offset(0, 1).Select
ActiveCell.NumberFormat = "mm/dd/yyyy"
ActiveCell.Offset(1, 1).Select
End Sub
Private Sub Calendar1_Click()
ActiveCell.Value = CDbl(Calendar1.Value)
ActiveCell.NumberFormat = "mm/dd/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:A20"), 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
Else: Calendar1.Visible = False
End If
End Sub