how to make auto date update work on a range of cells.

C

cashnic

Sorry, very new to formulas and code. The code below will populate a cell
with the update date/time when the cell next to it is updated. Works
GREAT...on that one cell! How do I apply this code to an entire column? I'm
sure I need to enter a range of cells somehow into this code but I don't know
how to do this.

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$D$7" Then
Target.Offset(0, 1) = Format$(Now, "dd/mm/yy hh:mm")
End If
End Sub
 
J

John Bundy

You were telling it to only do it for a particular cell address. You can do
it with the entire column D with this:
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 4 Then 'D is the 4th column
Target.Offset(0, 1) = Format$(Now, "dd/mm/yy hh:mm")
End If
End Sub
 
G

Gord Dibben

You asked this same question an hour ago and received the same answer you
just got here.

Why did I bother an hour ago?


Gord Dibben MS Excel MVP
 
C

cashnic

Sorry Gord, it was not intentional. I have not used this tool before and was
not sure whether I should ask my question as "new" or from an existing
string. My apologies, I appreciate the help!
 
G

Gord Dibben

The first time you asked was within another thread.

When you do that, don't start a new thread without waiting a while to see if
you get a response.

Sometimes you won't because people think that old thread was finished.

The you post a new thread.

We'll let you off this time since you are new here<g>


Gord
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top