• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Excel leave excising date in cell (calendar VBA)

mrwad

New Member
I am using VBA calendar to input dates in my workbook. I have added code to my worksheet to call calendar on double click of cell. So basically when I double click cell in range I get calendar form, where I pick up the date and then it is inserted in double clicked cell. The problem is if I already have some date in cell and double click it and then just close calendar instead of picking up some date it inserts 1.1.1990 or 00:00:00. How I can make to leave existing date if I just press close?

Code to call calendar form by double clicking cell in range:
Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)

  Dim xRg As Object

    If Not Intersect(Target, Range("E7:F187")) Is Nothing Then dateVariable = CalendarForm.GetDate
   
  For Each xRg In Selection.Cells
  xRg.Value = dateVariable
  Next xRg

   
End Sub
 
Back
Top