ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Entering static Date/Time (https://www.excelbanter.com/excel-programming/311584-entering-static-date-time.html)

GAMOSTEVE[_2_]

Entering static Date/Time
 

Thanks for the help - I changed to column C being the trigger for A an
B. I put the code below into the sheet. I get no errors, but nothin
happens in the sheet. Any ideas on what I have missed?

Thanks


Private Sub Sheet1(ByVal Target As Range)
If Target.Columns.Count 3 Then Exit Sub
If Target.Column < 3 Then
Exit Sub
For Each cell In Target
If Not IsEmpty(cell) Then
Cells(Target.Row, "A").Value = Date
Cells(Target.Row, "B").Value = Time
Columns("A:B").AutoFit
End If
Next

End Su

--
GAMOSTEV
-----------------------------------------------------------------------
GAMOSTEVE's Profile: http://www.excelforum.com/member.php...fo&userid=1476
View this thread: http://www.excelforum.com/showthread.php?threadid=26384


Tom Ogilvy

Entering static Date/Time
 
If you want this to fire when the entry is made in column C, then don't
change the name of the procedure. Paste it in the code module for the sheet
where you want this behavior. The below worked fine for me for entries in
column C.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Columns.Count 1 Then Exit Sub
If Target.Column < 3 Then _
Exit Sub
On Error GoTo ErrHandler
Application.EnableEvents = False
For Each cell In Target
If Not IsEmpty(cell) Then
Cells(Target.Row, "A").Value = Date
Cells(Target.Row, "B").Value = Time
Columns("A:B").AutoFit
End If
Next
ErrHandler:
Application.EnableEvents = True
End Sub


--
Regards,
Tom Ogilvy




"GAMOSTEVE" wrote in message
...

Thanks for the help - I changed to column C being the trigger for A and
B. I put the code below into the sheet. I get no errors, but nothing
happens in the sheet. Any ideas on what I have missed?

Thanks


Private Sub Sheet1(ByVal Target As Range)
If Target.Columns.Count 3 Then Exit Sub
If Target.Column < 3 Then
Exit Sub
For Each cell In Target
If Not IsEmpty(cell) Then
Cells(Target.Row, "A").Value = Date
Cells(Target.Row, "B").Value = Time
Columns("A:B").AutoFit
End If
Next

End Sub


--
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