ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Initialize data in new row? (https://www.excelbanter.com/excel-programming/274007-initialize-data-new-row.html)

Ken[_12_]

Initialize data in new row?
 
Hi. When data is entered into a new row, I want to initialize a value
into one of the row's cells. How would I do that?

Thanks!

Ken

Tom Ogilvy

Initialize data in new row?
 
Like a timestamp

right click on the worksheet and insert code like this:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Target.Count 1 Then Exit Sub
If Target.Row < 1 And Target.Column < 1 Then
If IsEmpty(Cells(Target.Row, 1)) Then
On Error GoTo ErrHandler
Application.EnableEvents = True
Cells(Target.Row, 1).Value = Date
Cells(Target.Row, 1).NumberFormat = "mm/dd/yyyy"
End If
End If
ErrHandler:
Application.EnableEvents = True
End Sub


--
Regards,
Tom Ogilvy

Ken wrote in message
om...
Hi. When data is entered into a new row, I want to initialize a value
into one of the row's cells. How would I do that?

Thanks!

Ken





All times are GMT +1. The time now is 12:38 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com