View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_3_] Bob Phillips[_3_] is offline
external usenet poster
 
Posts: 2,420
Default Put Value in a cell next to the active cell

Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "X3:X2580" '<== change to suit

On Error GoTo ws_exit
Application.EnableEvents = False

If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target

.Offset(0, -1).Value = Now
.Offset(0, -1).NumberFormat = "dd mmm yyyy hh:mm:ss"
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.


--
__________________________________
HTH

Bob

"richard" wrote in message
...
Hi

I have a calendar control which populates cells X$3$ to $X$2580. So If I
select cell X$5$ the calendar pops up and I select a date and this is then
entered into cell X5. What I also want to do is put Now() into cell $W$5
I have never used VBA in excel before only in access, so dont know about
active cells

any help greatly appreciated

Thanks

Richard