Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
MAS MAS is offline
external usenet poster
 
Posts: 19
Default Time and date each entry

Hi,

I am creating a spreadsheet to record and manage IT faults under the
following column headings.

TIME DATE Fault Description Reported By Reported
To Result

Is there any way to get Excel to generatenew time and date to reflect when
each Fault Description is entered on a new Row ?

Thanks


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Time and date each entry

Right click on the sheet tab and select view code.

put in code like this

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Target.Count 1 Then Exit Sub
If Target.Column = 3 Then
On Error GoTo errHandler
Application.EnableEvents = False
With Cells(Target.Row, 1)
.Value = Time
.NumberFormat = "hh:mm:ss"
End With
With Cells(Target.Row, 2)
.Value = Date
.NumberFormat = "mm/dd/yyyy"
End With
Columns("A:B").AutoFit
End If
errHandler:
Application.EnableEvents = True
End Sub

If you are not familiar with events, look at Chip Pearson's page
http://www.cpearson.com/excel/events.htm

--
Regards,
Tom Ogilvy

"MAS" wrote in message
...
Hi,

I am creating a spreadsheet to record and manage IT faults under the
following column headings.

TIME DATE Fault Description Reported By

Reported
To Result

Is there any way to get Excel to generatenew time and date to reflect when
each Fault Description is entered on a new Row ?

Thanks




  #3   Report Post  
Posted to microsoft.public.excel.programming
MAS MAS is offline
external usenet poster
 
Posts: 19
Default Time and date each entry

Tom

Thats it.. Cheers.

"Tom Ogilvy" wrote in message
...
Right click on the sheet tab and select view code.

put in code like this

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Target.Count 1 Then Exit Sub
If Target.Column = 3 Then
On Error GoTo errHandler
Application.EnableEvents = False
With Cells(Target.Row, 1)
.Value = Time
.NumberFormat = "hh:mm:ss"
End With
With Cells(Target.Row, 2)
.Value = Date
.NumberFormat = "mm/dd/yyyy"
End With
Columns("A:B").AutoFit
End If
errHandler:
Application.EnableEvents = True
End Sub

If you are not familiar with events, look at Chip Pearson's page
http://www.cpearson.com/excel/events.htm

--
Regards,
Tom Ogilvy

"MAS" wrote in message
...
Hi,

I am creating a spreadsheet to record and manage IT faults under the
following column headings.

TIME DATE Fault Description Reported By

Reported
To Result

Is there any way to get Excel to generatenew time and date to reflect
when
each Fault Description is entered on a new Row ?

Thanks






  #4   Report Post  
Posted to microsoft.public.excel.programming
MAS MAS is offline
external usenet poster
 
Posts: 19
Default Time and date each entry

Well Almost...

I have now found that when I protect the worksheet the date writes correctly
but the time does not get written to its cell ?

Neither the Date or Time Cells are locked and it makes no difference if I
apply or unapply validation rules ?

Any ideas folks !


"MAS" wrote in message
...
Tom

Thats it.. Cheers.

"Tom Ogilvy" wrote in message
...
Right click on the sheet tab and select view code.

put in code like this

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Target.Count 1 Then Exit Sub
If Target.Column = 3 Then
On Error GoTo errHandler
Application.EnableEvents = False
With Cells(Target.Row, 1)
.Value = Time
.NumberFormat = "hh:mm:ss"
End With
With Cells(Target.Row, 2)
.Value = Date
.NumberFormat = "mm/dd/yyyy"
End With
Columns("A:B").AutoFit
End If
errHandler:
Application.EnableEvents = True
End Sub

If you are not familiar with events, look at Chip Pearson's page
http://www.cpearson.com/excel/events.htm

--
Regards,
Tom Ogilvy

"MAS" wrote in message
...
Hi,

I am creating a spreadsheet to record and manage IT faults under the
following column headings.

TIME DATE Fault Description Reported By

Reported
To Result

Is there any way to get Excel to generatenew time and date to reflect
when
each Fault Description is entered on a new Row ?

Thanks








  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Time and date each entry

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Target.Count 1 Then Exit Sub
If Target.Column = 3 Then
On Error GoTo errHandler
Application.EnableEvents = False

' add line to unprotect
ActiveSheet.Unprotect

With Cells(Target.Row, 1)
.Value = Time
.NumberFormat = "hh:mm:ss"
End With
With Cells(Target.Row, 2)
.Value = Date
.NumberFormat = "mm/dd/yyyy"
End With
Columns("A:B").AutoFit
End If
errHandler:
Application.EnableEvents = True

' add line to protect
ActiveSheet.Protect
End Sub

if you have a password

Activesheet.Unprotect Password:="ABCD"


ActiveSheet.Protect Password:="ABCD"

--
Regards,
Tom Ogilvy


"MAS" wrote in message
...
Well Almost...

I have now found that when I protect the worksheet the date writes

correctly
but the time does not get written to its cell ?

Neither the Date or Time Cells are locked and it makes no difference if I
apply or unapply validation rules ?

Any ideas folks !


"MAS" wrote in message
...
Tom

Thats it.. Cheers.

"Tom Ogilvy" wrote in message
...
Right click on the sheet tab and select view code.

put in code like this

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Target.Count 1 Then Exit Sub
If Target.Column = 3 Then
On Error GoTo errHandler
Application.EnableEvents = False
With Cells(Target.Row, 1)
.Value = Time
.NumberFormat = "hh:mm:ss"
End With
With Cells(Target.Row, 2)
.Value = Date
.NumberFormat = "mm/dd/yyyy"
End With
Columns("A:B").AutoFit
End If
errHandler:
Application.EnableEvents = True
End Sub

If you are not familiar with events, look at Chip Pearson's page
http://www.cpearson.com/excel/events.htm

--
Regards,
Tom Ogilvy

"MAS" wrote in message
...
Hi,

I am creating a spreadsheet to record and manage IT faults under the
following column headings.

TIME DATE Fault Description Reported By
Reported
To Result

Is there any way to get Excel to generatenew time and date to reflect
when
each Fault Description is entered on a new Row ?

Thanks










Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Time entry auto changes to date and then time ? Carol @ Prison[_2_] Excel Worksheet Functions 1 November 25th 09 10:01 PM
Automate date & time entry Cheeris Excel Worksheet Functions 1 August 18th 09 10:47 PM
Time and Date Entry Shortcuts? Tammy Excel Worksheet Functions 5 January 4th 08 05:27 AM
Data Entry date/time? FARAZ QURESHI Excel Discussion (Misc queries) 3 January 1st 07 09:55 PM
Date and time entry Hans Knudsen[_2_] Excel Programming 1 November 27th 05 05:42 AM


All times are GMT +1. The time now is 01:52 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"