View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
JE McGimpsey JE McGimpsey is offline
external usenet poster
 
Posts: 4,624
Default Worksheet Change Event

One way:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
With Target
If .Count 1 Then Exit Sub
If Not Intersect(Range("D4:D2500"), .Cells) Is Nothing Then
Application.EnableEvents = False
If IsDate(.Value) Then _
.Value = DateSerial(Year(.Value), Month(.Value), 1)
Application.EnableEvents = True
End If
End With
End Sub


In article ,
"Steph" wrote:

Hello. Within the range of Sheet1 D4:D2500, how can I take a date that is
entered into a cell and convert the DAY to a 1, keeping all else the same?

So for example, if the user enters 12/15/2005 in cell D25, then I would like
the change event to trigger and convert that cell into 12/1/2005.

Thank you!