View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Date/time groupe

Made an error. Revision is:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Target.Count 1 Then Exit Sub
If Target.Column = 2 Then
With Target.Offset(0, -1)
If Not IsEmpty(Target.Value) Then
.Value = Now
.NumberFormat = "dd/mm/yyyy hh:mm"
.EntireColumn.AutoFit
End If
End With
End If
End Sub


--
Regards,
Tom Ogilvy


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

in the left dropdown at the top of the resulting module select

workbook

and in the right dropdown select Change (not selectionchange)

Private Sub Worksheet_Change(ByVal Target As Excel.Range)

End Sub

should appear.

I don't know your exact situation, but let us say we want to put a date

time
value in column A whenever an entry is made in column B

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
if target.count 1 then exit sub
if target.column = 2 then
With target.offset(0,-1)
if not isempty(.value) then
.Value = now
.Numberformat = "dd/mm/yyyy hh:mm"
.entireColumn.Autofit
end if
end with
End if
End Sub

for general information on events, see Chip Pearson's page on events
http://www.cpearson.com/excel/events.htm


--
Regards,
Tom Ogilvy




End Sub
"Johan H. Olsen" wrote in message
...
On Sun, 15 May 2005 19:36:17 +0200, Johan H. Olsen
wrote:

On Sun, 15 May 2005 13:23:26 -0400, "Tom Ogilvy"
wrote:

=now()

in the cell, then hit F9 to update. It will actually update each time

the
sheet is calculated.

Yes i see. but this only updates the one cell i am in. This is
supposed to be a row of cells and each time we use a new line, we need
to type inn the date and the time. This we would like to have more
"auto".
Sorry if i didn't explain myself good enough, its not so easy to make
one selves understood in English.

:-)


And the date/time in the cells that already has values should NOT be
updated. Then all the cells get the same time/date..