View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Mikey B[_2_] Mikey B[_2_] is offline
external usenet poster
 
Posts: 9
Default Date recording on a cell

Thanks alot Norman. That works perfectly.
Your "You're the Man" plaque is in the mail. :)

"Norman Jones" wrote:

Hi Miley,

Try:

'=============
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range
Dim rng2 As Range
Dim rCell As Range

Set rng = Range("A1:A20") '<<==== CHANGE

Set rng2 = Intersect(rng, Target)

If Not rng2 Is Nothing Then
On Error GoTo XIT
Application.EnableEvents = False
For Each rCell In rng2.Cells
With rCell
If Not IsEmpty(.Value) Then
.Offset(0, 1).Value = Now
.Offset(0, 1).NumberFormat = "mm/dd/yy h:mm"
Else
.Offset(0, 1).Value = ""
End If
End With
Next rCell
End If
XIT:
Application.EnableEvents = True
End Sub
'<<=============

This is worksheet event code and should be pasted into the worksheets's code
module (not a standard module and not the workbook's ThisWorkbook module):

Right-click the worksheet's tab
Select 'View Code' from the menu and paste the code.
Alt-F11 to return to Excel.


---
Regards,
Norman


"Mikey B" wrote in message
...
I have only an average skill level in Excel, but I have a good amout of
skill
with Access and VBA.
I was wondering if there was a way to automatically record the present
date
when a cell data is entered/changed. This date can be stored in the
comments
field or in another cell.

I know the user could just enter the date in another cell manually but I
have been asked to make this an automatic process by my boss.