+ Reply to Thread
Results 1 to 3 of 3

Pop-Up calendar

  1. #1
    Registered User
    Join Date
    01-27-2005
    Posts
    2

    Pop-Up calendar

    I am VERY new to the world of VBA (I think that's what they call it) so ANY help is greatly appreciated.

    I copied and pasted some codes from a few websites and I've finally got a calendar to pop-up whenever I click on a specified cell, then it enters the selected date into the cell. The code is as follows:
    ------

    Private Sub Calendar1_Click()
    ActiveCell.Value = CDbl(Calendar1.Value)
    ActiveCell.NumberFormat = "dd-mmm-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("B7,B10,B13,B16,B19,B22,B25,B28,B31,B34,B37,B40,B43,B46,B49,B52,B55"), 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
    ------

    How should a code be written to perform the same task in column D of the same worksheet. For example, D7,D10,D13 etc. Thanx.

  2. #2
    Registered User
    Join Date
    06-21-2004
    Location
    Phoenix, Az
    Posts
    30

    Lightbulb

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Target.Cells.Count > 1 Then Exit Sub
    If Not Application.Intersect(Range("B7,B10,B13,B16,B19,B22,B25,B28,B31,B34,B37,B40,B43 ,B46,B49,B52,B55"), Target) Is Nothing And Not Application.Intersect(Range("D7,D10,D13,D16,D19,D22,D25,D28,D31,D34,D37,D40,D43 ,D46,D49,D52,D55"), 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

  3. #3
    Registered User
    Join Date
    01-27-2005
    Posts
    2
    Quote Originally Posted by crispbd
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Target.Cells.Count > 1 Then Exit Sub
    If Not Application.Intersect(Range("B7,B10,B13,B16,B19,B22,B25,B28,B31,B34,B37,B40,B43 ,B46,B49,B52,B55"), Target) Is Nothing And Not Application.Intersect(Range("D7,D10,D13,D16,D19,D22,D25,D28,D31,D34,D37,D40,D43 ,D46,D49,D52,D55"), 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
    Thanks for the help. Unfortunately that doesn't work either. For some reason even the B column cells don't even display a calendar anymore.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1