Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Date recording on a cell
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. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Date recording on a cell
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. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Macro - a way of recording the date | Excel Worksheet Functions | |||
Recording the date another cell is edited or modified. | Excel Worksheet Functions | |||
recording a data entry date | Excel Worksheet Functions | |||
recording the date when record was entered in cell in Excel | Excel Worksheet Functions | |||
Recording the last saved date of an external file in a cell | Excel Programming |