![]() |
How to set date cell when its row changes
I want to customize Excel such that when a user changes any column in a
particular row, a date column in that row will be updated to the current date-time. Do I need a macro to do that? I have a software background, but not in macros. Can someone jot for me please some code that would do that? Thanks!! |
How to set date cell when its row changes
You can use the Change Event
See Chip Pearson's page on Events Private Sub Worksheet_Change(ByVal Target As Range) If Target.Row = 3 And Target.Rows.Count = 1 Then Application.EnableEvents = False Cells(3, "F").Value = Now() Application.EnableEvents = True End If End Sub Right click on the sheet tab and select view code. Put in code similar to the above. -- Regards, Tom Ogilvy "Jack Gur" <Jack wrote in message ... I want to customize Excel such that when a user changes any column in a particular row, a date column in that row will be updated to the current date-time. Do I need a macro to do that? I have a software background, but not in macros. Can someone jot for me please some code that would do that? Thanks!! |
How to set date cell when its row changes
To update date for several rows use the following script
Private Sub Worksheet_Change(ByVal Target As Range) Dim R As Variant For Each R In Target.Rows Application.EnableEvents = False Cells(R.Row, "F").Value = Now() Application.EnableEvents = True Next End Sub "Tom Ogilvy" wrote: You can use the Change Event See Chip Pearson's page on Events Private Sub Worksheet_Change(ByVal Target As Range) If Target.Row = 3 And Target.Rows.Count = 1 Then Application.EnableEvents = False Cells(3, "F").Value = Now() Application.EnableEvents = True End If End Sub Right click on the sheet tab and select view code. Put in code similar to the above. -- Regards, Tom Ogilvy "Jack Gur" <Jack wrote in message ... I want to customize Excel such that when a user changes any column in a particular row, a date column in that row will be updated to the current date-time. Do I need a macro to do that? I have a software background, but not in macros. Can someone jot for me please some code that would do that? Thanks!! |
All times are GMT +1. The time now is 09:50 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com