![]() |
Entering static Date/Time
I'm trying to enter a date and a time in a worksheet if there is dat entered into a particular cell. Example - Cell A contains data or nul - if data, enter current date in Cell B and current time in cell C. Problem I keep running into, the date/time updates to current with dat entry into the next row. Anyone have any ideas -- GAMOSTEV ----------------------------------------------------------------------- GAMOSTEVE's Profile: http://www.excelforum.com/member.php...fo&userid=1476 View this thread: http://www.excelforum.com/showthread.php?threadid=26384 |
Entering static Date/Time
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Columns.Count 1 Then Exit Sub If Target.Column < 1 Then Exit Sub For Each cell In Target If Not IsEmpty(cell) Then Cells(Target.Row, "B").Value = Date Cells(Target.Row, "C").Value = Time Columns("B:C").AutoFit End If Next End Sub right click on the sheet tab and select view code. Paste in code like the above. -- Regards, Tom Ogilvy "GAMOSTEVE" wrote in message ... I'm trying to enter a date and a time in a worksheet if there is data entered into a particular cell. Example - Cell A contains data or null - if data, enter current date in Cell B and current time in cell C. Problem I keep running into, the date/time updates to current with data entry into the next row. Anyone have any ideas? -- GAMOSTEVE ------------------------------------------------------------------------ GAMOSTEVE's Profile: http://www.excelforum.com/member.php...o&userid=14762 View this thread: http://www.excelforum.com/showthread...hreadid=263848 |
Entering static Date/Time
Had some formatting problems:
Private Sub Worksheet_Change(ByVal Target As Range) Dim cell as Range If Target.Columns.Count 1 Then _ Exit Sub If Target.Column < 1 Then _ Exit Sub For Each cell In Target If Not IsEmpty(cell) Then Cells(Target.Row, "B").Value = Date Cells(Target.Row, "C").Value = Time Columns("B:C").AutoFit End If Next End Sub -- Regards, Tom Ogilvy "Tom Ogilvy" wrote in message ... Private Sub Worksheet_Change(ByVal Target As Range) If Target.Columns.Count 1 Then Exit Sub If Target.Column < 1 Then Exit Sub For Each cell In Target If Not IsEmpty(cell) Then Cells(Target.Row, "B").Value = Date Cells(Target.Row, "C").Value = Time Columns("B:C").AutoFit End If Next End Sub right click on the sheet tab and select view code. Paste in code like the above. -- Regards, Tom Ogilvy "GAMOSTEVE" wrote in message ... I'm trying to enter a date and a time in a worksheet if there is data entered into a particular cell. Example - Cell A contains data or null - if data, enter current date in Cell B and current time in cell C. Problem I keep running into, the date/time updates to current with data entry into the next row. Anyone have any ideas? -- GAMOSTEVE ------------------------------------------------------------------------ GAMOSTEVE's Profile: http://www.excelforum.com/member.php...o&userid=14762 View this thread: http://www.excelforum.com/showthread...hreadid=263848 |
All times are GMT +1. The time now is 05:22 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com