Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
I have this code so that when I write a name in column A, the date and time
appears both in column B. All I want is that the date appears in column B and the time in column C. Below is the code. Thanks in advance. Option Explicit Private Sub Worksheet_Change(ByVal Target As Range) Dim myRow As Long If Target.Cells.Count 1 Then Exit Sub 'one cell a time End If If Intersect(Target, Me.Range("a:a")) Is Nothing Then Exit Sub 'Look in column A only End If myRow = Target.Row On Error GoTo ErrHandler: With Me.Cells(myRow, "b") If IsEmpty(.Value) Then 'ok to add, the cell is empty Application.EnableEvents = False .NumberFormat = "dd/mm/yyyy hh:mm:ss" .Value = Now End If End With ErrHandler: Application.EnableEvents = True End Sub |
#2
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
hi
i edited the code some. tested and works in 03. Private Sub Worksheet_Change(ByVal Target As Range) Dim myRow As Long If Target.Cells.Count 1 Then Exit Sub 'one cell a time End If If Intersect(Target, Me.Range("a:a")) Is Nothing Then Exit Sub 'Look in column A only End If myRow = Target.Row On Error GoTo ErrHandler: With Me.Cells(myRow, "b") If IsEmpty(.Value) Then 'ok to add, the cell is empty Application.EnableEvents = False .NumberFormat = "dd/mm/yyyy" ' hh:mm:ss" .Value = Date End If End With With Me.Cells(myRow, "c") .NumberFormat = "hh:mm:ss" .Value = Time End With ErrHandler: Application.EnableEvents = True End Sub regards FSt1 "MAX" wrote: I have this code so that when I write a name in column A, the date and time appears both in column B. All I want is that the date appears in column B and the time in column C. Below is the code. Thanks in advance. Option Explicit Private Sub Worksheet_Change(ByVal Target As Range) Dim myRow As Long If Target.Cells.Count 1 Then Exit Sub 'one cell a time End If If Intersect(Target, Me.Range("a:a")) Is Nothing Then Exit Sub 'Look in column A only End If myRow = Target.Row On Error GoTo ErrHandler: With Me.Cells(myRow, "b") If IsEmpty(.Value) Then 'ok to add, the cell is empty Application.EnableEvents = False .NumberFormat = "dd/mm/yyyy hh:mm:ss" .Value = Now End If End With ErrHandler: Application.EnableEvents = True End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Calculating days & time left from start date/time to end date/time | Excel Worksheet Functions | |||
Combined date time cell to separate date & time components | Excel Discussion (Misc queries) | |||
Combined date time cell to separate date & time components | Excel Discussion (Misc queries) | |||
Combined date time cell to separate date & time components | Excel Discussion (Misc queries) | |||
Combined date time cell to separate date & time components | Excel Worksheet Functions |