Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I change the date automatically when a row has been updated 1

Status
Not open for further replies.

Aspesim

Technical User
Jan 7, 2009
15
EU
Thanks Skip


Hi Guys

To say I'm newbie at this is an understatement.

I need to know how to add the date (say in coloum L)in MS EXCEL on which the row (A - K) had been last modified.

I've read some threads on this but I don't understand them.

First of all where would you enter the code?

I'll learn one step at a time I guess so please be patient with me as I'll be back time and again until I get it right

Kindest Regards
Aspesim
 
Hi,

You must use a Worksheet Event: the Worksheet_Change event.

Right click your sheet tab and select View Code

Past this code into the code window.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim t As Range
    For Each t In Target
        Intersect(t.EntireRow, Cells(1, "L").EntireColumn).Value = Now
    Next
End Sub
change a value on your sheet and observe.

Skip,
[glasses]Don't let the Diatribe...
talk you to death![tongue]

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Thanks Skip it worked just great.

However: What do I enter if I want column A and all columns after L to be exempt from the automatic date entry?

Kindest Regards
Aspesim
 
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim t As Range
    For Each t In Target
        Intersect(t.EntireRow, [b]Range("A:K"),[/b] Cells(1, "L").EntireColumn).Value = Now
    Next
End Sub


Skip,
[glasses]Don't let the Diatribe...
talk you to death![tongue]

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
...oops

make that Range("B:L")

Skip,
[glasses]Don't let the Diatribe...
talk you to death![tongue]

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Hi Skip

Thanks for your replies. However when i make a change in coloumn A it stills updates the (Now)/ date cell although I made the Range("B:L"). Also any changes to cells after coloumn L updates the (Now) / date cell?

Aspesim
 
Code:
For Each t In Target
    If Not (Intersect(t, Range("B:L")) Is Nothing) Then
        Intersect(t.EntireRow, Range("A:K"), Cells(1, "L").EntireColumn).Value = Now
    End If
Next

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Sorry, I went off hald cocked!
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim t As Range
    For Each t In Target
        If Not Intersect(t, Range("B:K")) Is Nothing Then
            Intersect(t.EntireRow, Cells(1, "L").EntireColumn).Value = Now
        End If
    Next
End Sub


Skip,
[glasses]Don't let the Diatribe...
talk you to death![tongue]

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top